aboutsummaryrefslogtreecommitdiff
path: root/.nnnrc
blob: b3cf992111a6b96c5f9783b18e097eea8a364d70 (plain)
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
26
27
#!/usr/bin/env sh

if [ ! -d $HOME/.config/nnn/plugins ]; then
    curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh
fi

export NNN_PLUG='f:fzcd;v:imgview;j:autojump;p:preview-tui'
[ -f /usr/bin/trash ] && export NNN_TRASH=1
export NNN_FIFO=/tmp/nnn.fifo

# To support cd on quit (Ctrl-G)
# NOTE: The quitcd ONLY work when typing `n` instead of `nnn`.
n () {
    if [[ "${NNNLVL:-0}" -ge 1 ]]; then
        echo "nnn is already running"
        return
    fi

    NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

    \nnn "$@"

    if [ -f "$NNN_TMPFILE" ]; then
        . "$NNN_TMPFILE"
        rm -f "$NNN_TMPFILE" > /dev/null
    fi
}