My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 line
636 B

  1. #!/usr/bin/env sh
  2. # Description: Helper script for plugins
  3. #
  4. # Shell: POSIX compliant
  5. # Author: Anna Arad
  6. selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
  7. ## Ask nnn to switch to directory $1 in context $2.
  8. ## If $2 is not provided, the function asks explicitly.
  9. nnn_cd () {
  10. dir=$1
  11. if [ -z "$NNN_PIPE" ]; then
  12. echo "No pipe file found" 1>&2
  13. return
  14. fi
  15. if [ -n "$2" ]; then
  16. context=$2
  17. else
  18. echo -n "Choose context 1-4 (blank for current): "
  19. read context
  20. fi
  21. echo -n ${context:-0}$dir > $NNN_PIPE
  22. }
  23. cmd_exists () {
  24. which "$1" > /dev/null 2>&1
  25. echo $?
  26. }