Advertisement
Guest User

Untitled

a guest
Apr 27th, 2015
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # feh browser
  4. # (source: archlinux wiki)
  5.  
  6. shopt -s nullglob
  7.  
  8. [[ ! -f $1 ]] && { printf '%s\n' "${0}: first argument is not a file." 1>&2 ; exit 1 ; }
  9.  
  10. declare file=$(basename -- "$1") \
  11. dir=$(dirname -- "$1")
  12. declare -a arr=()
  13.  
  14. shift 1
  15.  
  16. cd -- "$dir" &&
  17. {
  18. for i in *
  19. do
  20. [[ -f $i ]] || continue
  21. arr+=("$i")
  22. [[ $i == $file ]] && c=$((${#arr[@]}-1))
  23. done
  24. }
  25.  
  26. (exec feh "$@" -- "${arr[@]:c}" "${arr[@]:0:c}" &)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement