README.md | 1 + misc/auto-completion/bash/nnn-completion.bash | 1 + misc/auto-completion/fish/nnn.fish | 1 + misc/auto-completion/zsh/_nnn | 1 + nnn.1 | 7 ++++++- plugins/README.md | 3 ++- src/nnn.c | 12 ++++++++++-- diff --git a/README.md b/README.md index d521d859712f3a58ecf986acb3951dbcf3c2a18c..07f277f45885b2cf1a1fab783f88f34fbc0e657a 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,7 @@ | sshfs, [rclone](https://rclone.org/), fusermount(3)/umount (macOS) | optional | mount, unmount remotes | | trash-cli | optional | trash files (default action: rm) | | vlock (Linux), bashlock (macOS), lock(1) (BSD),
peaclock (Haiku) | optional | terminal locker (fallback: [cmatrix](https://github.com/abishekvashok/cmatrix)) | | advcpmv (Linux) ([integration](https://github.com/jarun/nnn/wiki/Advanced-use-cases#show-cp-mv-progress)) | optional | copy, move progress | +| fortune | optional | random quotes in help screen | | `$VISUAL` (else `$EDITOR`), `$PAGER`, `$SHELL` | optional | fallback vi, less, sh | #### From a package manager diff --git a/misc/auto-completion/bash/nnn-completion.bash b/misc/auto-completion/bash/nnn-completion.bash index 863378a793c16f3dc7f9343af5b882986f8d4ea8..b498b63147c3d2bcfb40da45c301b40f7b483d49 100644 --- a/misc/auto-completion/bash/nnn-completion.bash +++ b/misc/auto-completion/bash/nnn-completion.bash @@ -19,6 +19,7 @@ -d -e -E -f + -F -g -H -K diff --git a/misc/auto-completion/fish/nnn.fish b/misc/auto-completion/fish/nnn.fish index 56cd425fe64c9d2ec0b0f58b39a0827d6dd639fc..82dfc36feebd9aa2ba571432af0a6f08a2dda38e 100644 --- a/misc/auto-completion/fish/nnn.fish +++ b/misc/auto-completion/fish/nnn.fish @@ -18,6 +18,7 @@ complete -c nnn -s d -d 'start in detail mode' complete -c nnn -s e -d 'open text files in $VISUAL/$EDITOR/vi' complete -c nnn -s E -d 'use EDITOR for undetached edits' complete -c nnn -s f -d 'use readline history file' +complete -c nnn -s F -d 'show fortune' complete -c nnn -s g -d 'regex filters' complete -c nnn -s H -d 'show hidden files' complete -c nnn -s K -d 'detect key collision' diff --git a/misc/auto-completion/zsh/_nnn b/misc/auto-completion/zsh/_nnn index e92bf3016bfbeeeecd179e8bbab0c68eaee80bad..d40ea684aec425a824be9bb28741d3550bce73ce 100644 --- a/misc/auto-completion/zsh/_nnn +++ b/misc/auto-completion/zsh/_nnn @@ -16,6 +16,7 @@ '(-d)-d[start in detail mode]' '(-e)-e[open text files in $VISUAL/$EDITOR/vi]' '(-E)-E[use EDITOR for undetached edits]' '(-f)-f[use readline history file]' + '(-F)-F[show fortune]' '(-g)-g[regex filters]' '(-H)-H[show hidden files]' '(-K)-K[detect key collision]' diff --git a/nnn.1 b/nnn.1 index f8b0966b26f97b4c44f0ec65d86750a604981238..400bb314fe51ee861f44f3a9a916ad4b75a992ef 100644 --- a/nnn.1 +++ b/nnn.1 @@ -13,6 +13,7 @@ .Op Ar -d .Op Ar -e .Op Ar -E .Op Ar -f +.Op Ar -F .Op Ar -g .Op Ar -H .Op Ar -K @@ -72,6 +73,9 @@ use $EDITOR for internal undetached edits .Pp .Fl f use readline history file +.Pp +.Fl F + show fortune in help and settings screen .Pp .Fl g use regex filters instead of substring match @@ -350,7 +354,8 @@ ----------------------------------- + ------------------------------------------------- Key:Command | Description ----------------------------------- + ------------------------------------------------- k:-_fuser -kiv $nnn* | Interactively kill process(es) using hovered file - l:_git log | Show git log + g:-_git diff* | Show git diff + l:-_git log* | Show git log n:-_vi /home/user/Dropbox/dir/note* | Take quick notes in a synced file/dir of notes p:-_less -iR $nnn* | Page through hovered file in less s:-_|smplayer -minigui $nnn | Play hovered media file, even unfinished download diff --git a/plugins/README.md b/plugins/README.md index e4182e3d1b878a28d50b8ef1536a29ae9da1515e..71155290940dfffb2b114920d1a776d0d10bd6d7 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -133,7 +133,8 @@ | Key:Command | Description | |---|---| | `k:-_fuser -kiv $nnn*` | Interactively kill process(es) using hovered file | -| `l:_git log` | Show git log | +| `g:-_git diff*` | Show git diff | +| `l:-_git log*` | Show git log | | `n:-_vi /home/user/Dropbox/dir/note*` | Take quick notes in a synced file/dir of notes | | `p:-_less -iR $nnn*` | Page through hovered file in less | | `s:-_\|smplayer -minigui $nnn` | Play hovered media file, even unfinished download | diff --git a/src/nnn.c b/src/nnn.c index 33066e4321bfa0b87ade5e6de100ae21c7791867..ff98a348cd78c07be42b89644700ba8604390e6b 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -399,8 +399,9 @@ #define STATE_AUTONEXT 0x10 #define STATE_MSG 0x20 #define STATE_TRASH 0x40 #define STATE_FORCEQUIT 0x80 +#define STATE_FORTUNE 0x100 -static uchar g_states; +static uint g_states; /* Options to identify file mime */ #if defined(__APPLE__) @@ -4131,6 +4132,9 @@ close(fd); return; } + if ((g_states & STATE_FORTUNE) && getutil("fortune")) + pipetof("fortune -s", fp); + start = end = helpstr; while (*end) { if (*end == '\n') { @@ -6575,6 +6579,7 @@ " -E use EDITOR for undetached edits\n" #ifndef NORL " -f use readline history file\n" #endif + " -F show fortune\n" " -g regex filters [default: string]\n" " -H show hidden files\n" " -K detect key collision\n" @@ -6739,7 +6744,7 @@ #endif while ((opt = (env_opts_id > 0 ? env_opts[--env_opts_id] - : getopt(argc, argv, "Ab:cdeEfgHKnop:QrRs:St:T:Vxh"))) != -1) { + : getopt(argc, argv, "Ab:cdeEfFgHKnop:QrRs:St:T:Vxh"))) != -1) { switch (opt) { case 'A': cfg.autoselect = 0; @@ -6768,6 +6773,9 @@ case 'f': #ifndef NORL rlhist = TRUE; #endif + break; + case 'F': + g_states |= STATE_FORTUNE; break; case 'g': cfg.regex = 1;