daily pastebin goal
18%
SHARE
TWEET

Untitled

a guest Jan 23rd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. user@/home/user $ ranger
  2.    
  3. /media/ubuntu/sdf675d7sf5sdfs7/some_directory
  4.    
  5. user@/home/user $
  6.    
  7. user@/media/ubuntu/sdf675d7sf5sdfs7/some_directory $
  8.    
  9. --choosedir=targetfile    
  10.     Allows you to pick a directory with ranger. When you exit ranger, it will write the last visited directory into targetfile.
  11.    
  12. alias ranger='ranger --choosedir=$HOME/.rangerdir; LASTDIR=`cat $HOME/.rangerdir`; cd "$LASTDIR"'
  13.    
  14. alias ranger='ranger --choosedir=$HOME/.rangerdir; LASTDIR=`cat $HOME/.rangerdir`; cd "$LASTDIR"'
  15.    
  16. function ranger-cd {
  17.     # create a temp file and store the name
  18.     tempfile="$(mktemp -t tmp.XXXXXX)"
  19.  
  20.     # run ranger and ask it to output the last path into the
  21.     # temp file
  22.     ranger --choosedir="$tempfile" "${@:-$(pwd)}"
  23.  
  24.     # if the temp file exists read and the content of the temp
  25.     # file was not equal to the current path
  26.     test -f "$tempfile" &&
  27.     if [ "$(cat -- "$tempfile")" != "$(echo -n `pwd`)" ]; then
  28.         # change directory to the path in the temp file
  29.         cd -- "$(cat "$tempfile")"
  30.     fi
  31.  
  32.     # its not super necessary to have this line for deleting
  33.     # the temp file since Linux should handle it on the next
  34.     # boot
  35.     rm -f -- "$tempfile"
  36. }
  37.    
  38. alias nav=ranger-cd
  39.    
  40. # This will run the function by Ctrl+O through returning
  41. # the string "ranger-cd" in addition to a new-line character
  42. # to act as Enter key-press
  43. bindkey -s "^o" "ranger-cdn"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top