My build of nnn with minor changes
 
 
 
 
 
 

46 lines
1.1 KiB

  1. #!/usr/bin/env sh
  2. # Description: Independent POSIX-compliant GUI application launcher.
  3. # Fuzzy find executables in $PATH and launch an application.
  4. # stdin, stdout, stderr are suppressed so CLI tools exit silently.
  5. #
  6. # To configure launch as an independent app launcher add a keybind
  7. # to open launch in a terminal e.g.,
  8. #
  9. # xfce4-terminal -e "${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/launch
  10. #
  11. # Requires: fzf or fzy
  12. #
  13. # Usage: launch [delay]
  14. # delay is in seconds, if omitted launch waits for 1 sec
  15. #
  16. # Integration with nnn: launch is installed with other plugins, nnn picks it up.
  17. #
  18. # Shell: POSIX compliant
  19. # Author: Arun Prakash Jana
  20. # shellcheck disable=SC2012
  21. # shellcheck disable=SC2086
  22. IFS=':'
  23. get_selection() {
  24. if which fzf >/dev/null 2>&1; then
  25. ls -H $PATH | sort | fzf
  26. elif which fzy >/dev/null 2>&1; then
  27. ls -H $PATH | sort | fzy
  28. else
  29. exit 1
  30. fi
  31. }
  32. if selection=$( get_selection ); then
  33. setsid "$selection" 2>/dev/null 1>/dev/null &
  34. if ! [ -z "$1" ]; then
  35. sleep "$1"
  36. else
  37. sleep 1
  38. fi
  39. fi