~kris/dots

srice

ref: 2dc7c2f7e39f562e3603676ef50c2df0a4723c19 srice/.config/fish/functions/nnncd.fish -rw-r--r-- 589 bytes
2dc7c2f7 — Kris Yotam update nvim plan9 theme, add hosts file, misc updates 6 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