"Fossies" - the Fresh Open Source Software Archive

Member "nnn-4.4/misc/quitcd/quitcd.fish" (23 Nov 2021, 1134 Bytes) of package /linux/misc/nnn-v4.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Fish source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "quitcd.fish": v4.3_vs_v4.4.

    1 # Rename this file to match the name of the function
    2 # e.g. ~/.config/fish/functions/n.fish
    3 # or, add the lines to the 'config.fish' file.
    4 
    5 function n --wraps nnn --description 'support nnn quit and change directory'
    6     # Block nesting of nnn in subshells
    7     if test -n "$NNNLVL"
    8         if [ (expr $NNNLVL + 0) -ge 1 ]
    9             echo "nnn is already running"
   10             return
   11         end
   12     end
   13 
   14     # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
   15     # To cd on quit only on ^G, remove the "-x" as in:
   16     #    set NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
   17     #    (or, to a custom path: set NNN_TMPFILE "/tmp/.lastd")
   18     # or, export NNN_TMPFILE after nnn invocation
   19     if test -n "$XDG_CONFIG_HOME"
   20         set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
   21     else
   22         set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd"
   23     end
   24 
   25     # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
   26     # stty start undef
   27     # stty stop undef
   28     # stty lwrap undef
   29     # stty lnext undef
   30 
   31     nnn $argv
   32 
   33     if test -e $NNN_TMPFILE
   34         source $NNN_TMPFILE
   35         rm $NNN_TMPFILE
   36     end
   37 end