aboutsummaryrefslogtreecommitdiff
path: root/nnn/.bash/nnn.bash
blob: ac5445cca00023cb8e1fcab90d3f29168a4541f5 (plain) (blame)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# NNN specific config options imported by .bashrc

# Default options:
#   A: no directory autoselection in Nav-as-you-Type mode
#   d: open in detailed mode
#   e: open text files in $VISUAL/$EDITOR/vi
#   o: disable file opening with `l` or `→` (only with `Enter`)
export NNN_OPTS="Adeo"
# Use trash-cli when deleting files
export NNN_TRASH=1
# Set per-context colors
export NNN_COLORS=4523
# nnn selection file
export NNN_SEL="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection"
# Bookmarks
export NNN_BMS="m:/media;M:$HOME/.local/media;g:$GIT;z:$NOTES"
# Plugin/commands keybindings
export NNN_PLUG="c:chksum;i:imgview;m:nmount;M:mtpmount"
export NNN_PLUG="$NNN_PLUG;z:-_vim $NOTES/index.md*"

# `cd-on-quit` functionality based on
#
#       https://github.com/jarun/nnn/wiki/Basic-use-cases#configure-cd-on-quit
#
n()
{
    # Block nesting of nnn in subshells
    if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
        echo "nnn is already running"
        return
    fi

    # The default behaviour is to cd on quit (nnn checks if NNN_TMPFILE
    # is set). To cd on quit only on ^G, remove the "export" as in:
    #
    #     NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
    #
    # NOTE: NNN_TMPFILE is fixed, should not be modified
    NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

    # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
    # stty start undef
    # stty stop undef
    # stty lwrap undef
    # stty lnext undef

    nnn "$@"

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