2020-02-08 09:36:18 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Read a directory to an array and sort it directories first.
|
|
|
|
|
|
|
|
: ${JGMENU_RESOURCE_OPENER=xdg-open}
|
|
|
|
|
|
|
|
DIRECTORY=${1:-$HOME}
|
|
|
|
|
2020-02-09 16:52:47 +01:00
|
|
|
# If '$DIRECTORY' is '/', unset it to avoid '//'.
|
2020-02-08 09:36:18 +01:00
|
|
|
[[ $DIRECTORY == / ]] && DIRECTORY=
|
|
|
|
|
|
|
|
for item in "$DIRECTORY"/*; do
|
|
|
|
if [[ -d $item ]]; then
|
|
|
|
dirs+=("${item##*/},^pipe(jgbrowser \"$DIRECTORY/${item##*/}\")")
|
|
|
|
else
|
2020-02-09 16:52:47 +01:00
|
|
|
if [[ -f $item ]]; then
|
2020-02-08 09:36:18 +01:00
|
|
|
files+=("${item##*/},xdg-open \"$DIRECTORY/${item##*/}\"")
|
|
|
|
fi
|
2020-02-09 16:52:47 +01:00
|
|
|
fi
|
2020-02-08 09:36:18 +01:00
|
|
|
done
|
|
|
|
|
2020-02-09 16:52:47 +01:00
|
|
|
printf "%b\n" "^sep(<small><i>${DIRECTORY:-/}</i></small>)"
|
2020-02-09 21:47:44 +01:00
|
|
|
printf "%b\n" " Otwórz w menadżerze plików,${JGMENU_RESOURCE_OPENER} \"${DIRECTORY:-/}\""
|
2020-02-15 23:27:35 +01:00
|
|
|
printf "%b\n" " Otwórz w terminalu,terminator --working-directory=\"${DIRECTORY:-/}\""
|
2020-02-08 09:36:18 +01:00
|
|
|
printf "%b\n" "^sep()"
|
2020-02-09 16:52:47 +01:00
|
|
|
if [ ${#dirs[@]} -ne 0 ]; then
|
|
|
|
printf "%b\n" "^sep(Katalogi)"
|
|
|
|
printf '%s\n' "${dirs[@]}"
|
|
|
|
fi
|
|
|
|
if [ ${#files[@]} -ne 0 ]; then
|
|
|
|
printf "%b\n" "^sep(Pliki)"
|
|
|
|
printf '%s\n' "${files[@]}"
|
|
|
|
fi
|