~kris/dots

srice

ref: ff7367cb2ef828502c3f7fde003f45d5daa33206 srice/.config/fish/functions/nnncd.fish -rw-r--r-- 589 bytes
ff7367cb — Kris Yotam add ram memory visualization script 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function nnncd --description "nnn file manager with cd on exit"
    # Block nesting of nnn in subshells
    if test -n "$NNNLVL" -a "$NNNLVL" -ge 1
        echo "nnn is already running"
        return
    end

    # Use -Q to quit on cd
    set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
    if test -z "$NNN_TMPFILE"
        set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd"
    end

    nnn -Q $argv

    if test -e "$NNN_TMPFILE"
        source "$NNN_TMPFILE"
        rm -f "$NNN_TMPFILE"
    end
end

# Alias n to nnncd
function n --description "nnn with cd on exit"
    nnncd $argv
end