~kris/dots

srice

ref: c776188f504eb2e42ec1d359bdfd97e513b02add srice/.config/fish/functions/nnncd.fish -rw-r--r-- 589 bytes
c776188f — Kris Yotam add bm bookmark manager and dsnip launcher 5 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