diff options
-rw-r--r-- | .circleci/config.yml | 2 | ||||
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | Makefile | 30 | ||||
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | misc/auto-completion/bash/nnn-completion.bash | 1 | ||||
-rw-r--r-- | misc/auto-completion/fish/nnn.fish | 1 | ||||
-rw-r--r-- | misc/auto-completion/zsh/_nnn | 1 | ||||
-rw-r--r-- | misc/haiku/Makefile | 21 | ||||
-rw-r--r-- | nnn.1 | 4 | ||||
-rw-r--r-- | plugins/README.md | 19 | ||||
-rwxr-xr-x | plugins/autojump | 23 | ||||
-rw-r--r-- | src/.clang-tidy | 2 | ||||
-rw-r--r-- | src/nnn.c | 50 |
13 files changed, 140 insertions, 25 deletions
diff --git a/.circleci/config.yml b/.circleci/config.yml index be6666c..5128196 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,7 +55,7 @@ jobs: echo echo "########## clang-tidy-9 ##########" clang-tidy-9 src/* -- -I/usr/include -I/usr/include/ncursesw - echo "########## checllcheck ##########" + echo "########## shellcheck ##########" find plugins/ -type f -not -name "*.md" -exec shellcheck -e SC1090 {} + package-and-publish: @@ -1,4 +1,4 @@ -nnn v3.4 +nnn v3.4 Emilia 2020-08-18 - icons with icon-specific colors (thanks @KlzXS) @@ -24,6 +24,7 @@ O_NERD := 0 # support icons-nerdfont O_QSORT := 0 # use Alexey Tourbin's QSORT implementation O_BENCH := 0 # benchmark mode (stops at first user input) O_NOSSN := 0 # enable session support +O_NOUG := 0 # disable user, group name in status bar # convert targets to flags for backwards compatibility ifneq ($(filter debug,$(MAKECMDGOALS)),) @@ -95,6 +96,10 @@ ifeq ($(O_NOSSN),1) CPPFLAGS += -DNOSSN endif +ifeq ($(O_NOUG),1) + CPPFLAGS += -DNOUG +endif + ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw) LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw) @@ -161,9 +166,20 @@ uninstall: strip: $(BIN) $(STRIP) $^ +upx: $(BIN) + $(STRIP) $^ + upx -qqq $^ + static: + # regular static binary make O_STATIC=1 strip mv $(BIN) $(BIN)-static + # static binary with icons-in-terminal support + make O_STATIC=1 O_ICONS=1 strip + mv $(BIN) $(BIN)-icons-static + # static binary with patched nerd font support + make O_STATIC=1 O_NERD=1 strip + mv $(BIN) $(BIN)-nerd-static dist: mkdir -p nnn-$(VERSION) @@ -178,16 +194,28 @@ sign: upload-local: sign static $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id)) + # upload sign file curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \ -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \ --upload-file nnn-$(VERSION).tar.gz.sig tar -zcf $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-static + # upload static binary curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-static-$(VERSION).x86_64.tar.gz' \ -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \ --upload-file $(BIN)-static-$(VERSION).x86_64.tar.gz + tar -zcf $(BIN)-icons-static-$(VERSION).x86_64.tar.gz $(BIN)-icons-static + # upload icons-in-terminal compiled static binary + curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-icons-static-$(VERSION).x86_64.tar.gz' \ + -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \ + --upload-file $(BIN)-icons-static-$(VERSION).x86_64.tar.gz + # upload patched nerd font compiled static binary + tar -zcf $(BIN)-nerd-static-$(VERSION).x86_64.tar.gz $(BIN)-nerd-static + curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-nerd-static-$(VERSION).x86_64.tar.gz' \ + -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \ + --upload-file $(BIN)-nerd-static-$(VERSION).x86_64.tar.gz clean: - $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig $(BIN)-static $(BIN)-static-$(VERSION).x86_64.tar.gz + $(RM) -f $(BIN) nnn-$(VERSION).tar.gz *.sig $(BIN)-static $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-icons-static $(BIN)-icons-static-$(VERSION).x86_64.tar.gz $(BIN)-nerd-static $(BIN)-nerd-static-$(VERSION).x86_64.tar.gz skip: ; @@ -16,7 +16,7 @@ href="https://github.com/jarun/nnn#features">Features</a>] [<a href="https://github.com/jarun/nnn#quickstart">Quickstart</a>] [<a href="https://github.com/jarun/nnn/tree/master/plugins#nnn-plugins">Plugins</a>] [<a -href="https://github.com/jarun/nnn/wiki/Performance">Performance</a>]</h3> +href="https://github.com/jarun/nnn/wiki">Documentation</a>]</h3> <br> @@ -24,7 +24,7 @@ href="https://github.com/jarun/nnn/wiki/Performance">Performance</a>]</h3> <br> -`nnn` (_n³_) is a full-featured terminal file manager. It's tiny and nearly 0-config with an incredible speed. +`nnn` (_n³_) is a full-featured terminal file manager. It's tiny and nearly 0-config with an [incredible speed](https://github.com/jarun/nnn/wiki/Performance). It is designed to be unobtrusive with smart workflows to match the trains of thought. @@ -146,11 +146,11 @@ It runs smoothly on the Pi, [Termux](https://www.youtube.com/embed/AbaauM7gUJw) 4. [Install plugins](https://github.com/jarun/nnn/tree/master/plugins#installation). 5. Use option `-x` to copy selected file paths to system clipboard and show notis on cp, mv, rm completion. 6. For a CLI-only environment, customize and use plugin [`nuke`](https://github.com/jarun/nnn/blob/master/plugins/nuke) with option `-c` (overrides `-e`). -7. Bid _ls_ goodbye! `alias ls='nnn -d'` :sunglasses: +7. Bid _ls_ goodbye! `alias ls='nnn -de'` :sunglasses: Don't memorize! Arrows (or <kbd>h</kbd> <kbd>j</kbd> <kbd>k</kbd> <kbd>l</kbd>), <kbd>/</kbd>, <kbd>q</kbd> suffice. <kbd>Tab</kbd> creates, cycles contexts. <kbd>?</kbd> lists shortcuts. -[![Wiki](https://img.shields.io/badge/documentation-nnn%20Wiki-important?maxAge=2592000)](https://github.com/jarun/nnn/wiki) +[![Wiki](https://img.shields.io/badge/RTFM-nnn%20Wiki-important?maxAge=2592000)](https://github.com/jarun/nnn/wiki) ## Developers @@ -176,6 +176,7 @@ Visit the [ToDo list](https://github.com/jarun/nnn/issues/719) to contribute or - [Open Source For You](https://www.opensourceforu.com/2019/12/nnn-this-feature-rich-terminal-file-manager-will-enhance-your-productivity/) - [Suckless Rocks](https://suckless.org/rocks/) - [Ubuntu Full Circle Magazine - Issue 135](https://fullcirclemagazine.org/issue-135/) +- [Wikipedia](https://en.wikipedia.org/wiki/Nnn_(file_manager)) ## Videos diff --git a/misc/auto-completion/bash/nnn-completion.bash b/misc/auto-completion/bash/nnn-completion.bash index d0c80e5..cb2b6f2 100644 --- a/misc/auto-completion/bash/nnn-completion.bash +++ b/misc/auto-completion/bash/nnn-completion.bash @@ -40,6 +40,7 @@ _nnn () -t -T -u + -U -V -w -x diff --git a/misc/auto-completion/fish/nnn.fish b/misc/auto-completion/fish/nnn.fish index d47c72e..fdd27f8 100644 --- a/misc/auto-completion/fish/nnn.fish +++ b/misc/auto-completion/fish/nnn.fish @@ -39,6 +39,7 @@ complete -c nnn -s S -d 'persistent session' complete -c nnn -s t -r -d 'timeout in seconds to lock' complete -c nnn -s T -r -d 'a d e r s t v' complete -c nnn -s u -d 'use selection (no prompt)' +complete -c nnn -s U -d 'show user and group' complete -c nnn -s V -d 'show program version and exit' complete -c nnn -s w -d 'hardware cursor mode' complete -c nnn -s x -d 'notis, sel to system clipboard' diff --git a/misc/auto-completion/zsh/_nnn b/misc/auto-completion/zsh/_nnn index 0de2bda..9a33020 100644 --- a/misc/auto-completion/zsh/_nnn +++ b/misc/auto-completion/zsh/_nnn @@ -37,6 +37,7 @@ args=( '(-t)-t[timeout to lock]:seconds' '(-T)-T[a d e r s t v]:key' '(-u)-u[use selection (no prompt)]' + '(-U)-U[show user and group]' '(-V)-V[show program version and exit]' '(-w)-C[hardware cursor mode]' '(-x)-x[notis, sel to system clipboard]' diff --git a/misc/haiku/Makefile b/misc/haiku/Makefile index 6ab4544..2f6d78a 100644 --- a/misc/haiku/Makefile +++ b/misc/haiku/Makefile @@ -17,9 +17,12 @@ O_NOMOUSE := 0 # no mouse support O_NOBATCH := 0 # no built-in batch renamer O_NOFIFO := 0 # no FIFO previewer support O_CTX8 := 0 # enable 8 contexts -O_ICONS := 0 # support icons +O_ICONS := 0 # support icons-in-terminal +O_NERD := 0 # support icons-nerdfont O_QSORT := 0 # use Alexey Tourbin's QSORT implementation O_BENCH := 0 # benchmark mode (stops at first user input) +O_NOSSN := 0 # enable session support +O_NOUG := 0 # disable user, group name in status bar # convert targets to flags for backwards compatibility ifneq ($(filter debug,$(MAKECMDGOALS)),) @@ -76,6 +79,10 @@ ifeq ($(O_ICONS),1) CPPFLAGS += -DICONS endif +ifeq ($(O_NERD),1) + CPPFLAGS += -DNERD +endif + ifeq ($(O_QSORT),1) CPPFLAGS += -DTOURBIN_QSORT endif @@ -84,6 +91,14 @@ ifeq ($(O_BENCH),1) CPPFLAGS += -DBENCH endif +ifeq ($(O_NOSSN),1) + CPPFLAGS += -DNOSSN +endif + +ifeq ($(O_NOUG),1) + CPPFLAGS += -DNOUG +endif + ifeq ($(shell $(PKG_CONFIG) ncursesw && echo 1),1) CFLAGS_CURSES ?= $(shell $(PKG_CONFIG) --cflags ncursesw) LDLIBS_CURSES ?= $(shell $(PKG_CONFIG) --libs ncursesw) @@ -100,7 +115,7 @@ ifeq ($(shell uname -s), Haiku) OBJS_HAIKU ?= misc/haiku/nm.o endif -CFLAGS += -Wall -Wextra +CFLAGS += -std=c11 -Wall -Wextra -Wshadow CFLAGS += $(CFLAGS_OPTIMIZATION) CFLAGS += $(CFLAGS_CURSES) @@ -168,10 +183,12 @@ sign: upload-local: sign static $(eval ID=$(shell curl -s 'https://api.github.com/repos/jarun/nnn/releases/tags/v$(VERSION)' | jq .id)) + # upload sign file curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=nnn-$(VERSION).tar.gz.sig' \ -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/pgp-signature' \ --upload-file nnn-$(VERSION).tar.gz.sig tar -zcf $(BIN)-static-$(VERSION).x86_64.tar.gz $(BIN)-static + # upload static binary curl -XPOST 'https://uploads.github.com/repos/jarun/nnn/releases/$(ID)/assets?name=$(BIN)-static-$(VERSION).x86_64.tar.gz' \ -H 'Authorization: token $(NNN_SIG_UPLOAD_TOKEN)' -H 'Content-Type: application/x-sharedlib' \ --upload-file $(BIN)-static-$(VERSION).x86_64.tar.gz @@ -33,6 +33,7 @@ .Op Ar -t secs .Op Ar -T key .Op Ar -u +.Op Ar -U .Op Ar -V .Op Ar -w .Op Ar -x @@ -147,6 +148,9 @@ supports the following options: .Fl u use selection if available, don't prompt to choose between selection and hovered entry .Pp +.Fl U + show user and group names in status bar +.Pp .Fl V show version and exit .Pp diff --git a/plugins/README.md b/plugins/README.md index 07aa7a8..772f28e 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -16,7 +16,7 @@ Plugins extend the capabilities of `nnn`. They are _executable_ scripts (or bina | Plugin (a-z) | Description | Lang | Dependencies | | --- | --- | --- | --- | -| [autojump](autojump) | Navigate to dir/path | sh | [jump](https://github.com/gsamokovarov/jump)/autojump | +| [autojump](autojump) | Navigate to dir/path | sh | [jump](https://github.com/gsamokovarov/jump)/autojump/zoxide | | [bookmarks](bookmarks) | Use named bookmarks managed with symlinks | sh | fzf | | [boom](boom) | Play random music from dir | sh | [moc](http://moc.daper.net/) | | [bulknew](bulknew) | Create multiple files/dirs at once | bash | sed, xargs, mktemp | @@ -94,6 +94,23 @@ To pick and run an unassigned plugin, press <kbd>Enter</kbd> (to _enter_ the plu To run a plugin at startup, use the option `-P` followed by the plugin key. +If the plugins list gets too long, try breaking them up into sections: + +``` +NNN_PLUG_PERSONAL='g:personal/convert2zoom;p:personal/echo' +NNN_PLUG_WORK='j:work/prettyjson;d:work/foobar' +NNN_PLUG_INLINE='e:_go run $nnn*' +NNN_PLUG_DEFAULT='1:bookmarks;2:ipinfo;p:preview-tui;o:fzz;b:nbak' +NNN_PLUG="$NNN_PLUG_PERSONAL;$NNN_PLUG_WORK;$NNN_PLUG_DEFAULT;$NNN_PLUG_INLINE" +export NNN_PLUG +``` + +Note: +- `'g:personal/convert2zoom'` will look in the personal sub-folder inside the plugin folder. +- `'b:boom;b:bookmarks` will result in only the first definition of *b* (`b:boom`) being used. +- A keybinding definition of more than 1 character will prevent nnn from starting. + + #### Skip directory refresh after running a plugin `nnn` refreshes the directory after running a plugin to reflect any changes by the plugin. To disable this (say while running the `mediainf` plugin on some filtered files), add a `-` before the plugin name: diff --git a/plugins/autojump b/plugins/autojump index 3bfe228..db10c84 100755 --- a/plugins/autojump +++ b/plugins/autojump @@ -1,14 +1,15 @@ #!/usr/bin/env sh -# Description: Navigate to directory using jump/autojump +# Description: Navigate to directory using jump/autojump/zoxide # # Dependencies: jump - https://github.com/gsamokovarov/jump # OR autojump - https://github.com/wting/autojump +# OR zoxide - https://github.com/ajeetdsouza/zoxide # -# Note: jump/autojump STORES NAVIGATION PATTERNS +# Note: The dependencies STORE NAVIGATION PATTERNS # # Shell: POSIX compliant -# Authors: Marty Buchaus, Dave Snider +# Authors: Marty Buchaus, Dave Snider, Tim Adler if [ -z "$NNN_PIPE" ]; then echo 'ERROR: NNN_PIPE is not set' | ${PAGER:-less} @@ -16,16 +17,26 @@ if [ -z "$NNN_PIPE" ]; then fi if which jump >/dev/null 2>&1; then - printf "jump to: " + printf "jump to : " read -r dir odir="$(jump cd "$dir")" printf "%s" "0c$odir" > "$NNN_PIPE" elif which autojump >/dev/null 2>&1; then - printf "jump to: " + printf "jump to : " read -r dir odir="$(autojump "$dir")" printf "%s" "0c$odir" > "$NNN_PIPE" +elif which zoxide >/dev/null 2>&1; then + if which fzf >/dev/null 2>&1; then + odir="$(zoxide query -i --)" + printf "%s" "0c$odir" > "$NNN_PIPE" + else + printf "jump to : " + read -r dir + odir="$(zoxide query -- "$dir")" + printf "%s" "0c$odir" > "$NNN_PIPE" + fi else - printf "jump/autojump missing" + printf "No supported autojump script found. (jump/autojump/zoxide are supported)" read -r _ fi diff --git a/src/.clang-tidy b/src/.clang-tidy index f94a365..a4dc28b 100644 --- a/src/.clang-tidy +++ b/src/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,readability-*,modernize-*,bugprone-*,misc-*,-misc-unused-parameters,google-runtime-int,-llvm-header-guard,fuchsia-restrict-system-includes,-clang-analyzer-valist.Uninitialized,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-security.insecureAPI.rand,-clang-analyzer-alpha.*,-readability-magic-numbers,-readability-braces-around-statements,-readability-isolate-declaration,-bugprone-narrowing-conversions' +Checks: 'clang-diagnostic-*,clang-analyzer-*,readability-*,modernize-*,bugprone-*,misc-*,-misc-unused-parameters,google-runtime-int,-llvm-header-guard,fuchsia-restrict-system-includes,-clang-analyzer-valist.Uninitialized,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-security.insecureAPI.rand,-clang-analyzer-alpha.*,-readability-magic-numbers,-readability-braces-around-statements,-readability-isolate-declaration,-bugprone-narrowing-conversions,-bugprone-reserved-identifier' WarningsAsErrors: '*' HeaderFilterRegex: '.*(?<!lookup3.c)$' FormatStyle: 'file' @@ -99,6 +99,8 @@ #endif #include <ftw.h> #include <wchar.h> +#include <pwd.h> +#include <grp.h> #if !defined(alloca) && defined(__GNUC__) /* @@ -250,6 +252,10 @@ typedef struct entry { off_t size; blkcnt_t blocks; /* number of 512B blocks allocated */ mode_t mode; +#ifndef NOUG + uid_t uid; + gid_t gid; +#endif ushort nlen; /* Length of file name */ uchar flags; /* Flags specific to the file */ } *pEntry; @@ -325,7 +331,8 @@ typedef struct { uint oldcolor : 1; /* Use older colorscheme */ uint stayonsel : 1; /* Disable auto-proceed on select */ uint dirctx : 1; /* Show dirs in context color */ - uint reserved : 11; /* Adjust when adding/removing a field */ + uint uidgid : 1; /* Show owner and group info */ + uint reserved : 10; /* Adjust when adding/removing a field */ } runstate; /* Contexts or workspaces */ @@ -5098,6 +5105,12 @@ static int dentfill(char *path, struct entry **ppdents) dentp->mode = sb.st_mode; dentp->size = sb.st_size; #endif + +#ifndef NOUG + dentp->uid = sb.st_uid; + dentp->gid = sb.st_gid; +#endif + dentp->flags = S_ISDIR(sb.st_mode) ? 0 : ((sb.st_nlink > 1) ? HARD_LINK : 0); if (entflags) { dentp->flags |= entflags; @@ -5570,6 +5583,24 @@ static void statusbar(char *path) addch(' '); addstr(get_lsperms(pent->mode)); addch(' '); +#ifndef NOUG + if (g_state.uidgid) { + struct passwd *pw = getpwuid(pent->uid); + struct group *gr = getgrgid(pent->gid); + + if (pw) + addstr(pw->pw_name); + else + addch('-'); + addch(' '); + + if (gr) + addstr(gr->gr_name); + else + addch('-'); + addch(' '); + } +#endif addstr(coolsize(pent->size)); addch(' '); addstr(ptr); @@ -7046,10 +7077,11 @@ nochange: if (xlines != LINES || xcols != COLS) continue; - if (idletimeout && idle == idletimeout) + if (idletimeout && idle == idletimeout) { lock_terminal(); /* Locker */ + idle = 0; + } - idle = 0; if (ndents) copycurname(); @@ -7333,6 +7365,9 @@ static void usage(void) " -t secs timeout to lock\n" " -T key sort order [a/d/e/r/s/t/v]\n" " -u use selection (no prompt)\n" +#ifndef NOUG + " -U show user and group\n" +#endif " -V show version\n" " -w place HW cursor on hovered\n" " -x notis, sel to system clipboard\n" @@ -7480,7 +7515,7 @@ int main(int argc, char *argv[]) while ((opt = (env_opts_id > 0 ? env_opts[--env_opts_id] - : getopt(argc, argv, "aAb:cCdDeEfFgHJKl:nop:P:QrRs:St:T:uVwxh"))) != -1) { + : getopt(argc, argv, "aAb:cCdDeEfFgHJKl:nop:P:QrRs:St:T:uUVwxh"))) != -1) { switch (opt) { #ifndef NOFIFO case 'a': @@ -7599,6 +7634,9 @@ int main(int argc, char *argv[]) case 'u': cfg.prefersel = 1; break; + case 'U': + g_state.uidgid = 1; + break; case 'V': fprintf(stdout, "%s\n", VERSION); return EXIT_SUCCESS; @@ -7854,10 +7892,6 @@ int main(int argc, char *argv[]) if (sort) set_sort_flags(sort); - /* Set the process group to current process */ - setpgid(0, 0); - tcsetpgrp(STDOUT_FILENO, getpid()); - opt = browse(initpath, session, pkey); #ifndef NOMOUSE |