-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path,nnn
executable file
·84 lines (71 loc) · 1.92 KB
/
,nnn
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
set -e
declare -r CURRENT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
# More info here:
# https://github.com/jarun/nnn/blob/master/misc/quitcd/quitcd.bash_zsh
#
# 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
export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# 0 = black
# 1 = red
# 2 = green
# 3 = yellow
# 4 = blue
# 5 = magenta
# 6 = cyan
# 7 = white
export NNN_COLORS='4231'
# Use _ for arbitrary non-background CLI commands
# Use * to skip user confirmation
# Use _| to run a GUI app
# Use -_ to disable directory refresh
NNN_PLUG='g:_git status'
NNN_PLUG+=';b:_nnn-bookmarks*'
NNN_PLUG+=';e:_,env'
#NNN_PLUG+=';h:_cdhome*'
#NNN_PLUG+=';H:_cdhome'
NNN_PLUG+=';P:preview-tui'
#NNN_PLUG+=';a:bookmarks'
NNN_PLUG+=';o:fzopen'
NNN_PLUG+=';p:_nnn-cd-clipboard*'
NNN_PLUG+=';s:_nnn-show-selection'
NNN_PLUG+=';y:-_,clip $nnn*'
NNN_PLUG+=';z:_nnn-zsh*'
export NNN_PLUG
# TODO: Figure out how to get this to work
#open_with="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins/nuke"
#[[ -f "$open_with" ]] && export NNN_OPENER="$open_with"
# Use `less` as opener
export PAGER='less'
export LESS='-Ri'
export NNN_OPENER=less
# Fix ordering
export LC_ALL=C
# Check key collisions
nnn -K
# Open FIFO
export NNN_FIFO="$(mktemp --suffix=-nnn -u)"
(umask 077; mkfifo "$NNN_FIFO")
# Open preview pane
if [[ -e ${TMUX%%,*} ]]; then
width=$(($(tput cols)-50))
tmux split-window -dh -l $width nnn-preview $NNN_FIFO
#tmux split-window \
#-dh \
#-e "NNN_FIFO=$NNN_FIFO" \
#-l $width zsh
fi
# Run nnn
# -c: cli-opener
# -d: detail mode
nnn -c $@
# Clean up FIFO
rm "$NNN_FIFO"
# Print the contents of $NNN_TMPFILE
#if [[ -f "$NNN_TMPFILE" ]]; then
#echo "NNN_TMPFILE: $(cat $NNN_TMPFILE)"
#rm -f $NNN_TMPFILE
#fi