Skip to content

Instantly share code, notes, and snippets.

@skt041959
Created December 1, 2015 15:57
Show Gist options
  • Save skt041959/1af221282a8a0b38c0cc to your computer and use it in GitHub Desktop.
Save skt041959/1af221282a8a0b38c0cc to your computer and use it in GitHub Desktop.
make feh open images under the same directory
#!/bin/bash
shopt -s nullglob
if [[ ! -f $1 ]]; then
echo "$0: first argument is not a file" >&2
exit 1
fi
file=$(basename -- "$1")
dir=$(dirname -- "$1")
arr=()
shift
cd -- "$dir"
for i in *; do
[[ -f $i ]] || continue
arr+=("$i")
[[ $i == $file ]] && c=$((${#arr[@]} - 1))
done
exec feh "$@" -. -- "${arr[@]:c}" "${arr[@]:0:c}" &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment