Program option to load session is now -s

- remove auto-stored session "@" on restore
- minor help update
This commit is contained in:
Arun Prakash Jana 2019-12-20 15:49:13 +05:30
parent 9725c17d20
commit 37988cf854
No known key found for this signature in database
GPG key ID: A75979F35C080412
5 changed files with 16 additions and 15 deletions

View file

@ -16,7 +16,6 @@ _nnn ()
-b -b
-c -c
-d -d
-e
-E -E
-g -g
-H -H
@ -28,6 +27,7 @@ _nnn ()
-Q -Q
-r -r
-R -R
-s
-S -S
-t -t
-v -v
@ -39,7 +39,7 @@ _nnn ()
COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") ) COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
elif [[ $prev == -p ]]; then elif [[ $prev == -p ]]; then
COMPREPLY=( $(compgen -f -d -- "$cur") ) COMPREPLY=( $(compgen -f -d -- "$cur") )
elif [[ $prev == -e ]]; then elif [[ $prev == -s ]]; then
local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") ) COMPREPLY=( $(cd "$sessions_dir" && compgen -f -d -- "$cur") )
elif [[ $cur == -* ]]; then elif [[ $cur == -* ]]; then

View file

@ -15,7 +15,6 @@ complete -c nnn -s a -d 'use access time'
complete -c nnn -s b -r -d 'bookmark key to open' -x -a '(echo $NNN_BMS | awk -F: -v RS=\; \'{print $1"\t"$2}\')' complete -c nnn -s b -r -d 'bookmark key to open' -x -a '(echo $NNN_BMS | awk -F: -v RS=\; \'{print $1"\t"$2}\')'
complete -c nnn -s c -d 'cli-only opener' complete -c nnn -s c -d 'cli-only opener'
complete -c nnn -s d -d 'start in detail mode' complete -c nnn -s d -d 'start in detail mode'
complete -c nnn -s e -r -d 'load session by name' -x -a '@\t"last session" (ls $sessions_dir)'
complete -c nnn -s E -d 'use EDITOR for undetached edits' complete -c nnn -s E -d 'use EDITOR for undetached edits'
complete -c nnn -s g -d 'regex filters' complete -c nnn -s g -d 'regex filters'
complete -c nnn -s H -d 'show hidden files' complete -c nnn -s H -d 'show hidden files'
@ -27,6 +26,7 @@ complete -c nnn -s p -r -d 'copy selection to file' -a '-\tstdout'
complete -c nnn -s Q -d 'disable quit confirmation' complete -c nnn -s Q -d 'disable quit confirmation'
complete -c nnn -s r -d 'show cp, mv progress (Linux-only)' complete -c nnn -s r -d 'show cp, mv progress (Linux-only)'
complete -c nnn -s R -d 'disable rollover at edges' complete -c nnn -s R -d 'disable rollover at edges'
complete -c nnn -s s -r -d 'load session by name' -x -a '@\t"last session" (ls $sessions_dir)'
complete -c nnn -s S -d 'start in disk usage analyzer mode' complete -c nnn -s S -d 'start in disk usage analyzer mode'
complete -c nnn -s t -d 'disable dir auto-select' complete -c nnn -s t -d 'disable dir auto-select'
complete -c nnn -s v -d 'show program version and exit' complete -c nnn -s v -d 'show program version and exit'

View file

@ -13,7 +13,6 @@ args=(
'(-b)-b[bookmark key to open]:key char' '(-b)-b[bookmark key to open]:key char'
'(-c)-c[cli-only opener]' '(-c)-c[cli-only opener]'
'(-d)-d[start in detail mode]' '(-d)-d[start in detail mode]'
'(-e)-e[load session]:session name'
'(-E)-E[use EDITOR for undetached edits]' '(-E)-E[use EDITOR for undetached edits]'
'(-g)-g[regex filters]' '(-g)-g[regex filters]'
'(-H)-H[show hidden files]' '(-H)-H[show hidden files]'
@ -25,6 +24,7 @@ args=(
'(-Q)-Q[disable quit confirmation]' '(-Q)-Q[disable quit confirmation]'
'(-r)-r[show cp, mv progress (Linux-only)]' '(-r)-r[show cp, mv progress (Linux-only)]'
'(-R)-R[disable rollover at edges]' '(-R)-R[disable rollover at edges]'
'(-s)-s[load session]:session name'
'(-S)-S[start in disk usage analyzer mode]' '(-S)-S[start in disk usage analyzer mode]'
'(-t)-t[disable dir auto-select]' '(-t)-t[disable dir auto-select]'
'(-v)-v[show program version and exit]' '(-v)-v[show program version and exit]'

8
nnn.1
View file

@ -10,7 +10,6 @@
.Op Ar -b key .Op Ar -b key
.Op Ar -c .Op Ar -c
.Op Ar -d .Op Ar -d
.Op Ar -e name
.Op Ar -E .Op Ar -E
.Op Ar -g .Op Ar -g
.Op Ar -H .Op Ar -H
@ -21,6 +20,7 @@
.Op Ar -Q .Op Ar -Q
.Op Ar -r .Op Ar -r
.Op Ar -R .Op Ar -R
.Op Ar -s name
.Op Ar -S .Op Ar -S
.Op Ar -v .Op Ar -v
.Op Ar -x .Op Ar -x
@ -56,9 +56,6 @@ supports the following options:
.Fl d .Fl d
detail mode detail mode
.Pp .Pp
.Fl "e name"
load a session by name
.Pp
.Fl E .Fl E
use $EDITOR for internal undetached edits use $EDITOR for internal undetached edits
.Pp .Pp
@ -92,6 +89,9 @@ supports the following options:
.Fl R .Fl R
disable rollover at edges disable rollover at edges
.Pp .Pp
.Fl "s name"
load a session by name
.Pp
.Fl S .Fl S
start in disk usage analyzer mode start in disk usage analyzer mode
.Pp .Pp

View file

@ -2945,7 +2945,8 @@ END:
if (!status) { if (!status) {
printmsg(messages[MSG_FAILED]); printmsg(messages[MSG_FAILED]);
xdelay(XDELAY_INTERVAL_MS); xdelay(XDELAY_INTERVAL_MS);
} } else if (restore)
unlink(spath);
return status; return status;
} }
@ -3474,7 +3475,7 @@ static void show_help(const char *path)
"6(Sh)Tab Cycle context%-11cd Detail view toggle\n" "6(Sh)Tab Cycle context%-11cd Detail view toggle\n"
"c/ Filter%-13cIns ^N Nav-as-you-type toggle\n" "c/ Filter%-13cIns ^N Nav-as-you-type toggle\n"
"aEsc Exit prompt%-9c^L F5 Redraw/clear prompt\n" "aEsc Exit prompt%-9c^L F5 Redraw/clear prompt\n"
"c. Hidden toggle%-11c? Help, conf\n" "c. Toggle hidden%-11c? Help, conf\n"
"9Q ^Q Quit%-20cq Quit context\n" "9Q ^Q Quit%-20cq Quit context\n"
"b^G QuitCD%-1c\n" "b^G QuitCD%-1c\n"
"1FILES\n" "1FILES\n"
@ -5488,7 +5489,6 @@ static void usage(void)
" -b key open bookmark key\n" " -b key open bookmark key\n"
" -c cli-only opener\n" " -c cli-only opener\n"
" -d detail mode\n" " -d detail mode\n"
" -e name load session by name\n"
" -E use EDITOR for undetached edits\n" " -E use EDITOR for undetached edits\n"
" -g regex filters [default: string]\n" " -g regex filters [default: string]\n"
" -H show hidden files\n" " -H show hidden files\n"
@ -5500,6 +5500,7 @@ static void usage(void)
" -Q no quit confirmation\n" " -Q no quit confirmation\n"
" -r use advcpmv patched cp, mv\n" " -r use advcpmv patched cp, mv\n"
" -R no rollover at edges\n" " -R no rollover at edges\n"
" -s name load session by name\n"
" -S du mode\n" " -S du mode\n"
" -t no dir auto-select\n" " -t no dir auto-select\n"
" -v show version\n" " -v show version\n"
@ -5646,7 +5647,7 @@ int main(int argc, char *argv[])
bool progress = FALSE; bool progress = FALSE;
#endif #endif
while ((opt = getopt(argc, argv, "HSKiab:cde:Egnop:QrRtvxh")) != -1) { while ((opt = getopt(argc, argv, "HSKiab:cdEgnop:QrRs:tvxh")) != -1) {
switch (opt) { switch (opt) {
case 'S': case 'S':
cfg.blkorder = 1; cfg.blkorder = 1;
@ -5668,9 +5669,6 @@ int main(int argc, char *argv[])
case 'c': case 'c':
cfg.cliopener = 1; cfg.cliopener = 1;
break; break;
case 'e':
session = optarg;
break;
case 'E': case 'E':
cfg.waitedit = 1; cfg.waitedit = 1;
break; break;
@ -5715,6 +5713,9 @@ int main(int argc, char *argv[])
case 'R': case 'R':
cfg.rollover = 0; cfg.rollover = 0;
break; break;
case 's':
session = optarg;
break;
case 't': case 't':
cfg.autoselect = 0; cfg.autoselect = 0;
break; break;