Advertisement
Guest User

Untitled

a guest
May 27th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. show_usage()
  4. {
  5. cat <<EOF
  6. Usage:
  7. List files: $(basename $0) list DIRECTORY [RG-OPTIONS]
  8. Open file: $(basename $0) open FILE
  9.  
  10. Either lists all files in the given directory with rg or opens the given file
  11. with the default application.
  12.  
  13. Example usage with rofi:
  14.  
  15. Call: rofi -show eth -modi eth:~/bin/eth-files,private:~/bin/private-files
  16.  
  17. ~/bin/eth-files:
  18. #!/bin/bash
  19. DIRECTORY="${HOME}/cloud/eth/"
  20. if [ \$# -eq 0 ]; then
  21. rofi-files list "\${DIRECTORY}"
  22. else
  23. rofi-files open "\${DIRECTORY}/\${1}"
  24. fi
  25.  
  26. ~/bin/private-files:
  27. #!/bin/bash
  28. DIRECTORY="${HOME}/cloud/"
  29. if [ \$# -eq 0 ]; then
  30. rofi-files "list" "\{$DIRECTORY}" \\
  31. -g "!/eth" \\ # folder is covered by other mode
  32. -g "!/bg" # ignore this folder too
  33. else
  34. rofi-files open "\${DIRECTORY}/\${1}"
  35. fi
  36. EOF
  37. }
  38.  
  39. ACTION="$1"
  40.  
  41. if [ "$ACTION" = "list" ]; then
  42. cd $2
  43. rg --files --follow ${@:3}
  44. elif [ "$ACTION" = "open" ]; then
  45. exo-open "$2" >/dev/null 2>&1
  46. exit;
  47. else
  48. show_usage
  49. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement