Merge branch 'master' into add-kdeconnect

This commit is contained in:
Juan Adrián Castro Quintana 2019-03-24 22:33:18 -07:00 committed by GitHub
commit 6c27098533
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 448 additions and 374 deletions

View file

@ -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.rand,-clang-analyzer-alpha.*,-readability-magic-numbers,-readability-braces-around-statements' 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.rand,-clang-analyzer-alpha.*,-readability-magic-numbers,-readability-braces-around-statements,-readability-isolate-declaration,-bugprone-narrowing-conversions'
WarningsAsErrors: '*' WarningsAsErrors: '*'
HeaderFilterRegex: '.*(?<!lookup3.c)$' HeaderFilterRegex: '.*(?<!lookup3.c)$'
FormatStyle: 'file' FormatStyle: 'file'

View file

@ -1,18 +1,33 @@
#### Bug reports #### BUG REPORTS
If it looks like a local environment issue, please try to debug yourself. Debugging local setup issues is not our top priority. If it looks like a local environment issue, please try to debug yourself. Debugging local setup issues is not our top priority.
Before opening an issue, please try to reproduce the issue on latest master. The bug you noticed might have already been fixed. Before opening an issue, please try to reproduce on latest master. The bug you noticed might have already been fixed.
If the issue can be reproduced on master, please make sure you provide the following: Useful links:
- exact steps to reproduce the issue - compile `nnn` from source - https://github.com/jarun/nnn#from-source
- details of operating system, desktop environment, terminal emulator and shell - debugging `nnn` - https://github.com/jarun/nnn/wiki/debugging-nnn
If the issue can be reproduced on master, log it.
Please provide the environment details. **If that's missing, the issue will be closed without any cited reason.**
If we need more information and there is no communication from the bug reporter within 7 days from the date of request, we will close the issue. If you have relevant information, resume discussion any time. If we need more information and there is no communication from the bug reporter within 7 days from the date of request, we will close the issue. If you have relevant information, resume discussion any time.
#### Feature requests #### FEATURE REQUESTS
Please consider contributing the feature back to `nnn` yourself. Feel free to discuss in the ToDo list thread. We are more than happy to help. Please consider contributing the feature back to `nnn` yourself. Feel free to discuss in the ToDo list thread. We are more than happy to help.
--- PLEASE DELETE THIS LINE AND EVERYTHING ABOVE --- --- PLEASE DELETE THIS LINE AND EVERYTHING ABOVE ---
#### Environment details (Put `x` in the checkbox along with the information)
[ ] Operating System:
[ ] Desktop Environment:
[ ] Terminal Emulator:
[ ] Shell:
[ ] Custom desktop opener (if applicable):
[ ] Issue exists on `nnn` master
#### Exact steps to reproduce the issue

View file

@ -1,3 +1,26 @@
nnn v2.4
2019-03-19
- FreeDesktop.org compliant trashing
- mark selected entries with `+`
- _wild_ mode (option `-w`, key <kbd>^W</kbd>) for _nav-as-you-type_
- POSIX-compliant GUI app launcher with drop-down menu (key <kbd>=</kbd>)
- new scripts:
- upload image to imgur
- send selection to Android using kdeconnect-cli
- show permissions in detail mode
- cp, mv progress bar for Linux (needs advcpmv) [BSD, macOS shows on <kbd>^T</kbd>]
- make libreadline an optional dep (reduces memory usage)
- minimize the number of redraws
- handle screen resize gracefully
- option `-d` to show hidden files (`NNN_SHOW_HIDDEN` is removed)
- additional key <kbd>K</kbd> to toggle selection
- change visit start dir key to <kbd>@</kbd>
- option `-C` to disable colors removed
- per-context initial directory replaced by program start dir
- marker msg when spawning new shell removed
- rename debug file to `nnndbg`
nnn v2.3 nnn v2.3
2019-02-19 2019-02-19

View file

@ -1,4 +1,4 @@
VERSION = 2.3 VERSION = 2.4
PREFIX ?= /usr/local PREFIX ?= /usr/local
MANPREFIX ?= $(PREFIX)/share/man MANPREFIX ?= $(PREFIX)/share/man

View file

@ -1,6 +1,4 @@
## nnn ## nnn (_type less, do more_)
Noice is Not Noice, a noicer fork...
<p align="center"> <p align="center">
<a href="https://github.com/jarun/nnn/releases/latest"><img src="https://img.shields.io/github/release/jarun/nnn.svg?maxAge=600" alt="Latest release" /></a> <a href="https://github.com/jarun/nnn/releases/latest"><img src="https://img.shields.io/github/release/jarun/nnn.svg?maxAge=600" alt="Latest release" /></a>
@ -20,17 +18,15 @@ Noice is Not Noice, a noicer fork...
[![nnn video](https://i.imgur.com/ZB5UdQ8.jpg)](https://www.youtube.com/watch?v=U2n5aGqou9E "Click to see nnn in action!") [![nnn video](https://i.imgur.com/ZB5UdQ8.jpg)](https://www.youtube.com/watch?v=U2n5aGqou9E "Click to see nnn in action!")
<p align="center"><i>nnn in action! (Thanks Luke Smith for the video!)</i></a></p> <p align="center"><i>video of nnn in action (an earlier release)</i></a></p>
`nnn` is smooth... like butter. It's also one of the fastest and most lightweight file managers you have ever used. It comes in a `~50KB` binary using `~3.5MB` resident memory at runtime. `nnn` is one of the fastest and most lightweight file managers you have ever used (`~50KB` binary, `~3.5MB` resident memory usage, [highly optimized](https://github.com/jarun/nnn/wiki/performance-factors) code). And yet, it doesn't lack in features!
Runs on Linux, macOS, Raspberry Pi, BSD, Cygwin, Linux subsystem for Windows and Termux on Android. `nnn` works seamlessly with your DE and favourite GUI utilities. It runs on Linux, macOS, Raspberry Pi, BSD, Cygwin, Linux subsystem for Windows and Termux on Android.
`nnn` works with your DE and favourite GUI utilities, has a unique _navigate-as-you-type_ mode with auto-select, disk usage analyzer mode, bookmarks, contexts, application launcher, familiar navigation shortcuts, shell spawning, quick notes and much more. Have as many scripts as you want to extend the power of `nnn`! Pick from the [scripts repository](https://github.com/jarun/nnn/tree/master/user-scripts) or add your own.
It supports as many scripts as you need! Integrate utilities like sxiv (view images in directory) or fzy (fuzzy search subtree) with available scripts (or your own), transfer selected files using lftp or use it as a (neo)vim plugin. Refer to the wiki [How to](https://github.com/jarun/nnn/wiki/How-to) for more such use cases. [Quickstart](#quickstart) and see how `nnn` simplifies long desktop sessions. When you are ready for more, start [hacking `nnn`](https://github.com/jarun/nnn/wiki/hacking-nnn).
[Quickstart](#quickstart) and see how `nnn` simplifies those long desktop sessions.
*Love smart and efficient utilities? Explore [my repositories](https://github.com/jarun?tab=repositories). Buy me a cup of coffee if they help you.* *Love smart and efficient utilities? Explore [my repositories](https://github.com/jarun?tab=repositories). Buy me a cup of coffee if they help you.*
@ -48,6 +44,7 @@ It supports as many scripts as you need! Integrate utilities like sxiv (view ima
- [Release packages](#release-packages) - [Release packages](#release-packages)
- [From source](#from-source) - [From source](#from-source)
- [Shell completion](#shell-completion) - [Shell completion](#shell-completion)
- [Quickstart](#quickstart)
- [Usage](#usage) - [Usage](#usage)
- [Cmdline options](#cmdline-options) - [Cmdline options](#cmdline-options)
- [Keyboard shortcuts](#keyboard-shortcuts) - [Keyboard shortcuts](#keyboard-shortcuts)
@ -60,7 +57,6 @@ It supports as many scripts as you need! Integrate utilities like sxiv (view ima
- [File indicators](#file-indicators) - [File indicators](#file-indicators)
- [Configuration](#configuration) - [Configuration](#configuration)
- [Help](#help) - [Help](#help)
- [Quickstart](#quickstart)
- [User scripts](#user-scripts) - [User scripts](#user-scripts)
- [Troubleshooting](#troubleshooting) - [Troubleshooting](#troubleshooting)
- [Tmux configuration](#tmux-configuration) - [Tmux configuration](#tmux-configuration)
@ -70,15 +66,16 @@ It supports as many scripts as you need! Integrate utilities like sxiv (view ima
- [Why fork?](#why-fork) - [Why fork?](#why-fork)
- [Mentions](#mentions) - [Mentions](#mentions)
- [Developers](#developers) - [Developers](#developers)
- [Contributions](#contributions)
#### FEATURES #### FEATURES
- Modes - Modes
- Detail (default), light, disk usage analyzer (du) - Detail (default), light
- File picker, vim (or neovim) plugin - Disk usage analyzer (block/apparent)
- File picker, (neo)vim plugin
- Navigation - Navigation
- *Navigate-as-you-type* with auto-select directory - *Navigate-as-you-type* with auto-select directory
- *Wild load* for *navigate-as-you-type*
- 4 contexts (_aka_ tabs _aka_ workspaces) - 4 contexts (_aka_ tabs _aka_ workspaces)
- Bookmarks; pin and visit a directory - Bookmarks; pin and visit a directory
- Familiar, easy shortcuts (arrows, <kbd>~</kbd>, <kbd>-</kbd>, <kbd>@</kbd>) - Familiar, easy shortcuts (arrows, <kbd>~</kbd>, <kbd>-</kbd>, <kbd>@</kbd>)
@ -102,6 +99,7 @@ It supports as many scripts as you need! Integrate utilities like sxiv (view ima
- Copy, move, delete, archive, link selection - Copy, move, delete, archive, link selection
- FreeDesktop compliant trash (needs trash-cli) - FreeDesktop compliant trash (needs trash-cli)
- Show copy, move progress on Linux (needs avdcpmv) - Show copy, move progress on Linux (needs avdcpmv)
- Script to view directory and file diff for selection
- Transfer files using lftp - Transfer files using lftp
- Batch rename (needs vidir) - Batch rename (needs vidir)
- Per-context directory color (default: blue) - Per-context directory color (default: blue)
@ -113,7 +111,7 @@ It supports as many scripts as you need! Integrate utilities like sxiv (view ima
- Change directory at exit (*easy* shell integration) - Change directory at exit (*easy* shell integration)
- Edit file in EDITOR or open in PAGER - Edit file in EDITOR or open in PAGER
- Take quick notes - Take quick notes
- Terminal locker integration - Lock the terminal (needs a locker)
- Shortcut reference a keypress away - Shortcut reference a keypress away
- Unicode support - Unicode support
- Follows Linux kernel coding style - Follows Linux kernel coding style
@ -134,13 +132,13 @@ It supports as many scripts as you need! Integrate utilities like sxiv (view ima
| xdg-open (Linux), open(1) (macOS), cygstart (Cygwin) | desktop opener | | xdg-open (Linux), open(1) (macOS), cygstart (Cygwin) | desktop opener |
| file | determine file type | | file | determine file type |
| coreutils (cp, mv, rm), findutils (xargs) | copy, move and remove files | | coreutils (cp, mv, rm), findutils (xargs) | copy, move and remove files |
| trash-cli | trash files (instead of delete) | | trash-cli | trash files (default: delete) |
| mediainfo or exiftool | multimedia file details | | mediainfo or exiftool | multimedia file details |
| atool, patool ([integration](https://github.com/jarun/nnn/wiki/How-to#integrate-patool)) | create, list and extract archives | | atool, patool ([integration](https://github.com/jarun/nnn/wiki/hacking-nnn#integrate-patool)) | create, list and extract archives |
| fzy | app launcher with drop-down menu | | fzy | app launcher with drop-down menu |
| vidir (from moreutils) | batch rename dir entries | | vidir (from moreutils) | batch rename dir entries |
| vlock (Linux), bashlock (macOS), lock(1) (BSD) | terminal locker | | vlock (Linux), bashlock (macOS), lock(1) (BSD) | terminal locker |
| advcpmv (Linux) ([integration](https://github.com/jarun/nnn/wiki/How-to#show-cp-mv-progress)) | copy, move progress | | advcpmv (Linux) ([integration](https://github.com/jarun/nnn/wiki/hacking-nnn#show-cp-mv-progress)) | copy, move progress |
| $EDITOR (overridden by $VISUAL, if defined) | edit files (fallback vi) | | $EDITOR (overridden by $VISUAL, if defined) | edit files (fallback vi) |
| $PAGER (less, most) | page through files (fallback less) | | $PAGER (less, most) | page through files (fallback less) |
| $SHELL | spawn a shell, run script (fallback sh) | | $SHELL | spawn a shell, run script (fallback sh) |
@ -149,6 +147,7 @@ It supports as many scripts as you need! Integrate utilities like sxiv (view ima
- [Alpine Linux](https://pkgs.alpinelinux.org/packages?name=nnn) (`apk add nnn`) - [Alpine Linux](https://pkgs.alpinelinux.org/packages?name=nnn) (`apk add nnn`)
- [Arch Linux](https://www.archlinux.org/packages/community/x86_64/nnn/) (`pacman -S nnn`) - [Arch Linux](https://www.archlinux.org/packages/community/x86_64/nnn/) (`pacman -S nnn`)
- [CRUX portdb](https://crux.nu/portdb/?a=search&q=nnn) (`prt-get depinst nnn`)
- [Debian](https://packages.debian.org/search?keywords=nnn&searchon=names&exact=1) (`apt-get install nnn`) - [Debian](https://packages.debian.org/search?keywords=nnn&searchon=names&exact=1) (`apt-get install nnn`)
- [Fedora](https://apps.fedoraproject.org/packages/nnn) (`dnf install nnn`) - [Fedora](https://apps.fedoraproject.org/packages/nnn) (`dnf install nnn`)
- [FreeBSD](https://www.freshports.org/misc/nnn) (`pkg install nnn`) - [FreeBSD](https://www.freshports.org/misc/nnn) (`pkg install nnn`)
@ -182,13 +181,25 @@ To cook yourself, download the [latest stable release](https://github.com/jarun/
`PREFIX` is supported, in case you want to install to a different location. `PREFIX` is supported, in case you want to install to a different location.
- Compilation information for [Raspberry Pi](https://github.com/jarun/nnn/issues/182) - Compilation for [Raspberry Pi](https://github.com/jarun/nnn/issues/182)
- Instructions for [Cygwin](https://github.com/jarun/nnn/wiki/Cygwin-instructions) - Instructions for [Cygwin](https://github.com/jarun/nnn/wiki/Cygwin-instructions)
#### Shell completion #### Shell completion
Option completion scripts for Bash, Fish and Zsh can be found in respective subdirectories of [`scripts/auto-completion/`](scripts/auto-completion). Please refer to your shell's manual for installation instructions. Option completion scripts for Bash, Fish and Zsh can be found in respective subdirectories of [`scripts/auto-completion/`](scripts/auto-completion). Please refer to your shell's manual for installation instructions.
#### QUICKSTART
1. Install the [utilities required](#utility-dependencies) for your regular activities.
2. Configure [cd on quit](https://github.com/jarun/nnn/wiki/hacking-nnn#cd-on-quit).
3. Optionally open all text files in EDITOR (fallback vi): `export NNN_USE_EDITOR=1`
4. Run `n`.
5. To use `nnn` as a GUI app launcher with fuzzy selection menu, drop [`nlaunch`](https://github.com/jarun/nnn/blob/master/user-scripts/nlaunch) somewhere in your `$PATH`.
6. Don't memorize keys. Arrows, <kbd>/</kbd> and <kbd>q</kbd> suffice. Press <kbd>?</kbd> for help on keyboard shortcuts anytime.
- For additional functionality [setup custom scripts](#user-scripts).
- Visit the wiki page [hacking `nnn`](https://github.com/jarun/nnn/wiki/hacking-nnn) for many more specific usecases.
#### USAGE #### USAGE
#### Cmdline options #### Cmdline options
@ -213,7 +224,7 @@ optional args:
-s string filters [default: regex] -s string filters [default: regex]
-S du mode -S du mode
-v show version -v show version
-w wild mode -w wild load
-h show help -h show help
``` ```
@ -259,7 +270,7 @@ Help & settings, file details, media info and archive listing are shown in the P
#### Leader key #### Leader key
The Leader key (<kbd>`</kbd> or <kbd>^/</kbd>) provides a powerful multi-functional navigation mechanism. It is case-sensitive and understands contexts, bookmarks and handy location shortcuts. The Leader key provides a powerful multi-functional navigation mechanism. It is case-sensitive and understands contexts, bookmarks and location shortcuts.
| Key | Function | | Key | Function |
|:---:| --- | |:---:| --- |
@ -277,8 +288,8 @@ The Leader key (<kbd>`</kbd> or <kbd>^/</kbd>) provides a powerful multi-functio
Contexts serve the purpose of exploring multiple directories simultaneously. 4 contexts are available. The status of the contexts are shown in the top left corner: Contexts serve the purpose of exploring multiple directories simultaneously. 4 contexts are available. The status of the contexts are shown in the top left corner:
- the current context is in reverse - the current context is in reverse
- other used contexts are underlined - other active contexts are underlined
- rest are unused - rest are inactive
To switch to a context press the Leader key followed by the context number (1-4). To switch to a context press the Leader key followed by the context number (1-4).
@ -288,7 +299,7 @@ When a context is quit, the next active context is selected. If the last active
##### Context-specific color ##### Context-specific color
Each context can have its own color for directories specified: Each context can have its own directory color specified:
export NNN_CONTEXT_COLORS='1234' export NNN_CONTEXT_COLORS='1234'
colors: 0-black, 1-red, 2-green, 3-yellow, 4-blue (default), 5-magenta, 6-cyan, 7-white colors: 0-black, 1-red, 2-green, 3-yellow, 4-blue (default), 5-magenta, 6-cyan, 7-white
@ -304,23 +315,23 @@ To copy multiple absolute file paths:
- navigate to another file in the same directory to select a range of files - navigate to another file in the same directory to select a range of files
- press <kbd>^Y</kbd> again to save the selection and exit selection mode. - press <kbd>^Y</kbd> again to save the selection and exit selection mode.
_NOTE:_ If you are on BSD/macOS, please check the [BSD terminal issue](https://github.com/jarun/nnn#bsd-terminal-issue) with <kbd>^Y</kbd> for workaround.
Selected files are visually indicated by a `+`. Selected files are visually indicated by a `+`.
The files in the list can now be copied (<kbd>P</kbd>), moved (<kbd>V</kbd>) or removed (<kbd>X</kbd>). The selection can now be listed, copied, moved, removed, archived or linked.
To list the file paths copied to memory press <kbd>y</kbd>.
File paths are copied to the temporary file `DIR/.nnncp`, where `DIR` (by priority) is: File paths are copied to the temporary file `DIR/.nnncp`, where `DIR` (by priority) is:
$HOME or, $HOME or,
$TMPDIR or,
/tmp /tmp
$TMPDIR or,
The path is shown in the help and configuration screen. The path is shown in the help and configuration screen.
#### Filters #### Filters
Filters support regexes by default to instantly (search-as-you-type) list the matching entries in the current directory. Filters support regexes (default) to instantly (search-as-you-type) list the matching entries in the current directory.
Common use cases: Common use cases:
- to list all matches starting with the filter expression, start the expression with a `^` (caret) symbol - to list all matches starting with the filter expression, start the expression with a `^` (caret) symbol
@ -339,7 +350,7 @@ When there's a unique match and it's a directory, `nnn` auto selects the directo
This mode takes navigation to the next level when short, unique keypress sequences are possible. For example, to reach `nnn` development directory (located at `~/GitHub/nnn`) from my `$HOME` (which is the default directory the terminal starts in), I use the sequence <kbd>g</kbd><kbd>n</kbd>. This mode takes navigation to the next level when short, unique keypress sequences are possible. For example, to reach `nnn` development directory (located at `~/GitHub/nnn`) from my `$HOME` (which is the default directory the terminal starts in), I use the sequence <kbd>g</kbd><kbd>n</kbd>.
The **_wild mode_** program option can be extremely handy for users who use this mode constantly. The entries are unsorted when the directory loads. Applying filters sorts the entries (with directories on top). Directory color is disabled in this mode. The **_wild load_** option can be extremely handy for users who use this mode constantly. The entries are unsorted when the directory loads. Applying filters sorts the entries (with directories on top). Directory color is disabled in this mode.
#### File indicators #### File indicators
@ -365,8 +376,9 @@ The following indicators are used in the detail view:
| --- | --- | | --- | --- |
| `NNN_BMS='d:~/Documents;D:~/Docs archive/'` | specify bookmarks (max 10) | | `NNN_BMS='d:~/Documents;D:~/Docs archive/'` | specify bookmarks (max 10) |
| `NNN_OPENER=mimeopen` | custom file opener | | `NNN_OPENER=mimeopen` | custom file opener |
| `NNN_OPENER_DETACH=1` | do not block when invoking file opener |
| `NNN_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] | | `NNN_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] |
| `NNN_IDLE_TIMEOUT=300` | idle time to lock terminal [default: disabled] | | `NNN_IDLE_TIMEOUT=300` | idle seconds before locking terminal [default: disabled] |
| `NNN_COPIER='copier.sh'` | system clipboard copier script [default: none] | | `NNN_COPIER='copier.sh'` | system clipboard copier script [default: none] |
| `NNN_SCRIPT=/home/user/scripts[/script.sh]` | path to script dir or a single script | | `NNN_SCRIPT=/home/user/scripts[/script.sh]` | path to script dir or a single script |
| `NNN_NOTE=/home/user/Dropbox/Public/notes` | path to note file [default: none] | | `NNN_NOTE=/home/user/Dropbox/Public/notes` | path to note file [default: none] |
@ -384,20 +396,6 @@ The following indicators are used in the detail view:
$ man nnn $ man nnn
To lookup keyboard shortcuts at runtime, press <kbd>?</kbd>. To lookup keyboard shortcuts at runtime, press <kbd>?</kbd>.
#### QUICKSTART
1. Install the [utilities required](#utility-dependencies) for your regular activities.
2. Configure [cd on quit](https://github.com/jarun/nnn/wiki/How-to#cd-on-quit).
3. Optionally open all text files in EDITOR (fallback vi):
export NNN_USE_EDITOR=1
4. Run `n`.
5. To use `nnn` as a GUI app launcher with fuzzy selection menu, drop [`nlaunch`](https://github.com/jarun/nnn/blob/master/user-scripts/nlaunch) somewhere in your `$PATH`.
6. Don't memorize keys. Arrows, <kbd>/</kbd> and <kbd>q</kbd> suffice. Press <kbd>?</kbd> for help on keyboard shortcuts anytime.
- For additional functionality [setup custom scripts](#user-scripts).
- Visit the [How to](https://github.com/jarun/nnn/wiki/How-to) for many more specific usecases.
#### USER SCRIPTS #### USER SCRIPTS
`nnn` can invoke custom scripts in the current directory (`$PWD` for the script) with the currently selected file name as the argument. `nnn` can invoke custom scripts in the current directory (`$PWD` for the script) with the currently selected file name as the argument.
@ -446,6 +444,8 @@ Restrict opening 0-byte files due to [unexpected behaviour](https://github.com/j
- one can argue my approach deviates from the goal of the original project - keep the utility `suckless`. `noice` was rudimentary. In my opinion evolution is the taste of time. - one can argue my approach deviates from the goal of the original project - keep the utility `suckless`. `noice` was rudimentary. In my opinion evolution is the taste of time.
- I would like to have a bit of control on what features are added in the name of desktop integration. A feature-bloat is the last thing in my mind. Check out [nnn design considerations](https://github.com/jarun/nnn/wiki/nnn-design-considerations) for more details. - I would like to have a bit of control on what features are added in the name of desktop integration. A feature-bloat is the last thing in my mind. Check out [nnn design considerations](https://github.com/jarun/nnn/wiki/nnn-design-considerations) for more details.
Trivia: The name `nnn` stands for _Noice is Not Noice, a noicer fork..._.
#### MENTIONS #### MENTIONS
- [FOSSMint](https://www.fossmint.com/nnn-linux-terminal-file-browser/) - [FOSSMint](https://www.fossmint.com/nnn-linux-terminal-file-browser/)
@ -462,6 +462,4 @@ Restrict opening 0-byte files due to [unexpected behaviour](https://github.com/j
2. Copyright © 2014-2016 Dimitris Papastamos 2. Copyright © 2014-2016 Dimitris Papastamos
3. Copyright © 2016-2019 [Arun Prakash Jana](https://github.com/jarun) 3. Copyright © 2016-2019 [Arun Prakash Jana](https://github.com/jarun)
#### CONTRIBUTIONS Contributions are welcome. Please visit the [ToDo list](https://github.com/jarun/nnn/issues/213).
We need contributors. Please visit the [ToDo list](https://github.com/jarun/nnn/issues/213).

171
nnn.1
View file

@ -1,4 +1,4 @@
.Dd Feb 19, 2019 .Dd Mar 19, 2019
.Dt NNN 1 .Dt NNN 1
.Os .Os
.Sh NAME .Sh NAME
@ -29,145 +29,9 @@ opens the current working directory by default if
is not specified. is not specified.
.Sh KEYBINDS .Sh KEYBINDS
.Pp .Pp
NAVIGATION Press \fB?\fR in
.Pp .Nm
.Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact to see the list of keybinds.
.It Ic [Up], k
Move to previous entry
.It Ic [Down], j
Move to next entry
.It Ic [Left], h
Go to parent directory
.It Ic [Right], [Enter], l
Open file or enter directory
.It Ic [PgUp], ^U
Scroll up half a page
.It Ic [PgDn], ^D
Scroll down half a page
.It Ic [Home], g, ^A
Move to the first entry
.It Ic [End], G, ^E
Move to the last entry
.It Ic ~
Change to the HOME directory
.It Ic &
Change to initial directory
.It Ic \-
Change to the last visited directory
.It Ic \&.
Toggle show hidden . (dot) files
.It Ic /
Change filter (more information below)
.It Ic [Insert], ^T
Toggle navigate-as-you-type mode
.It Ic b
Pin current directory
.It Ic ^B
Visit pinned directory
.It Ic d
Toggle detail view
.It Ic Tab, ^I
Next context, ask to create if none
.It Ic ,, ^/
Leader key
.It Ic N, LeaderN
Switch to context N
.It Ic Esc
Exit prompt
.It Ic ^L
Force a redraw, clear prompt
.It Ic q
Quit the current context
.It Ic ^G
Quit and change directory
.It Ic Q, ^Q
Quit
.It Ic \&?
Help and configuration screen
.El
.Pp
FILES
.Pp
.Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact
.It Ic ^O
Open with an application
.It Ic n
Create a new file, directory or link(s) to selection
.It Ic D
Show entry details
.It Ic ^R
Rename selected entry
.It Ic r
Batch rename
.It Ic K, ^Y
Toggle selection mode
.It Ic Y
Select all entries in dir
.It Ic Space, ^K
Select entry and copy absolute path
.It Ic y
Show selection list
.It Ic P
Copy files from selection
.It Ic V
Move files from selection
.It Ic X
Delete files from selection
.It Ic ^X
Delete entry
.It Ic f
Archive files
.It Ic F
List files in archive
.It Ic ^F
Extract archive in current directory
.It Ic m, M
Show brief/full media info
.It Ic e
Open entry in EDITOR (fallback vi)
.It Ic p
Open entry in PAGER (fallback less)
.El
.Pp
ORDER TOGGLES
.Pp
.Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact
.It Ic ^J
Toggle disk usage analyzer mode
.It Ic S
Toggle sort by apparent size
.It Ic ^W
Wild mode
.It Ic t
Toggle sort by time modified
.It Ic s
Toggle sort by file size
.El
.Pp
MISC
.Pp
.Bl -tag -width "l, [Right], [Return] or C-mXXXX" -offset indent -compact
.It Ic \&!, ^]
Spawn SHELL in current directory (fallback sh)
.It Ic C
Execute entry
.It Ic R, ^V
Run or pick a script to run
.It Ic L
Lock terminal
.It Ic ^P
Show command prompt
.It Ic ^N
Take note
.It Ic =
Launcher
.El
.Pp
Backing up one directory level will set the cursor position at the
directory you came out of.
.Pp
Help & settings, file details, media info and archive listing are shown in the
PAGER. Use the PAGER-specific keys in these screens.
.Sh OPTIONS .Sh OPTIONS
.Pp .Pp
.Nm .Nm
@ -204,7 +68,7 @@ supports the following options:
show version and exit show version and exit
.Pp .Pp
.Fl w .Fl w
wild mode - entries unsorted on directory load wild load - entries unsorted on directory load
.Pp .Pp
.Fl h .Fl h
show program help and exit show program help and exit
@ -212,31 +76,31 @@ supports the following options:
.Nm .Nm
uses \fIxdg-open\fR (on Linux) and \fIopen(1)\fR (on macOS) as the desktop opener. uses \fIxdg-open\fR (on Linux) and \fIopen(1)\fR (on macOS) as the desktop opener.
.Pp .Pp
There is no configuration file. Settings work on environment variables. Please There is no configuration file. Settings work on environment variables. See ENVIRONMENT section below.
refer to the ENVIRONMENT section below.
.Pp .Pp
Configuring Configuring
.Nm .Nm
to change to the last visited directory on quit requires shell integration in a to change to the last visited directory on quit requires shell integration in a
few easy steps. Please visit the project page (linked below) for the few easy steps. Look up NNN_TMPFILE in the ENVIRONMENT section below.
instructions.
.Sh CONTEXTS .Sh CONTEXTS
Contexts serve the purpose of exploring multiple directories simultaneously. 4 contexts Contexts serve the purpose of exploring multiple directories simultaneously. 4 contexts
are available. The status of the contexts are shown in the top left corner: are available. The status of the contexts are shown in the top left corner:
.Pp .Pp
- the current context is in reverse - the current context is in reverse
.br .br
- other used contexts are underlined - other active contexts are underlined
.br .br
- rest are unused - rest are inactive
.Pp .Pp
To switch to a context press the Leader key followed by the context number (1-4). To switch to a context press the Leader key followed by the context number (1-4).
.Pp .Pp
The first time a context is entered, it copies the state of the last visited context. Each context remembers its last visited directory. The first time a context is entered, it copies the state of the last visited context. Each context remembers its last visited directory.
.Pp .Pp
When a context is quit, the next active context is selected. If the last active context is quit, the program quits. When a context is quit, the next active context is selected. If the last active context is quit, the program quits.
.Pp
Each context can have its own directory color specified. See ENVIRONMENT section below.
.Sh FILTERS .Sh FILTERS
Filters support regexes by default to instantly (search-as-you-type) list the matching Filters support regexes (default) to instantly (search-as-you-type) list the matching
entries in the current directory. entries in the current directory.
.Pp .Pp
Common use cases: Common use cases:
@ -255,7 +119,7 @@ allowing continuous navigation. Works best with the \fBarrow keys\fR.
.br .br
When there's a unique match and it's a directory, `nnn` auto selects the directory and enters it in this mode. When there's a unique match and it's a directory, `nnn` auto selects the directory and enters it in this mode.
.br .br
The \fIwild mode\fR can be extremely handy for users who use the \fInavigate-as-you-type\fR mode constantly. The entries are unsorted when the directory loads. Applying filters sorts the entries (with directories on top). Directory color is disabled in this mode. The \fIwild load\fR option can be extremely handy for users who use the \fInavigate-as-you-type\fR mode constantly. The entries are unsorted when the directory loads. Applying filters sorts the entries (with directories on top). Directory color is disabled in this mode.
.Sh SELECTION MODE .Sh SELECTION MODE
The absolute path of a single file can be copied to clipboard by pressing \fI^K\fR if The absolute path of a single file can be copied to clipboard by pressing \fI^K\fR if
NNN_COPIER is set (see ENVIRONMENT section below). NNN_COPIER is set (see ENVIRONMENT section below).
@ -271,9 +135,7 @@ Press \fI^Y\fR again to save the selection and exit selection mode.
.Pp .Pp
Selected files are visually indicated by a \fB+\fR. Selected files are visually indicated by a \fB+\fR.
.br .br
The files in the list can now be copied, moved or removed using respective keyboard shortcuts. The files in the list can now be listed, copied, moved, removed, archived or linked.
.Pp
To list the selected files press \fIy\fR.
.Sh ENVIRONMENT .Sh ENVIRONMENT
The SHELL, EDITOR (VISUAL, if defined) and PAGER environment variables take precedence The SHELL, EDITOR (VISUAL, if defined) and PAGER environment variables take precedence
when dealing with the !, e and p commands respectively. A single combination to arguments is supported for SHELL and PAGER. when dealing with the !, e and p commands respectively. A single combination to arguments is supported for SHELL and PAGER.
@ -291,6 +153,11 @@ when dealing with the !, e and p commands respectively. A single combination to
export NNN_OPENER=mimeopen export NNN_OPENER=mimeopen
.Ed .Ed
.Pp .Pp
\fBNNN_OPENER_DETACH:\fR do not block when invoking file opener.
.Bd -literal
export NNN_OPENER_DETACH=1
.Ed
.Pp
\fBNNN_CONTEXT_COLORS:\fR string of color codes for each context, e.g.: \fBNNN_CONTEXT_COLORS:\fR string of color codes for each context, e.g.:
.Bd -literal .Bd -literal
export NNN_CONTEXT_COLORS='1234' export NNN_CONTEXT_COLORS='1234'

View file

@ -16,4 +16,4 @@ complete -c nnn -s p -r -d 'copy selection to file'
complete -c nnn -s s -d 'use substring match for filters' complete -c nnn -s s -d 'use substring match for filters'
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 v -d 'show program version and exit' complete -c nnn -s v -d 'show program version and exit'
complete -c nnn -s w -d 'wild mode' complete -c nnn -s w -d 'wild load'

View file

@ -20,7 +20,7 @@ args=(
'(-s)-s[use substring match for filters]' '(-s)-s[use substring match for filters]'
'(-S)-S[start in disk usage analyzer mode]' '(-S)-S[start in disk usage analyzer mode]'
'(-v)-v[show program version and exit]' '(-v)-v[show program version and exit]'
'(-w)-w[wild mode]' '(-w)-w[wild load]'
'*:filename:_files' '*:filename:_files'
) )
_arguments -S -s $args _arguments -S -s $args

31
scripts/nlay/README.md Normal file
View file

@ -0,0 +1,31 @@
## nlay
`nlay` (*NnnpLAY*) is a customizable media type or action handler
### Usage
`nlay` is not used by `nnn` now. However, the bash script can be used to run desktop search utility or screensaver:
nlay file type
file: absolute path to file ("" for an action)
type: type of media or action
### Default apps
* gnome-search-tool, catfish - file search
* vlock - terminal screensaver (alternatives - cmatrix, termsaver)
### Perks
- simple to modify (extensive in-file notes, comments and indicative code)
- handle files by category (e.g. plaintext, search, screensaver)
- support for multiple apps by order of preference
- run app in the foreground or silently detached in the background
- optionally add app arguments
### Tips to modify
- set `app=` in any category to change the player
- set `opts=` to use app options
- toggle `bg=` to enable or disable running app silently (`stdout` and `stderr` redirected to `/dev/null`) in background. E.g., vim (CLI) should be verbose and in the foreground while Sublime Text (GUI) can be started silently in the background.
- enable the commented out code under `ENABLE_FILE_TYPE_HANDLING` to handle specific file extensions e.g. use a different app than the one used for the category.

88
src/dbg.h Normal file
View file

@ -0,0 +1,88 @@
/*
* BSD 2-Clause License
*
* Copyright (C) 2014-2016, Lazaros Koromilas <lostd@2f30.org>
* Copyright (C) 2014-2016, Dimitris Papastamos <sin@2f30.org>
* Copyright (C) 2016-2019, Arun Prakash Jana <engineerarun@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#ifdef DBGMODE
static int DEBUG_FD;
static int xprintf(int fd, const char *fmt, ...)
{
char buf[BUFSIZ];
int r;
va_list ap;
va_start(ap, fmt);
r = vsnprintf(buf, sizeof(buf), fmt, ap);
if (r > 0)
r = write(fd, buf, r);
va_end(ap);
return r;
}
static int enabledbg()
{
FILE *fp = fopen("/tmp/nnndbg", "w");
if (!fp) {
perror("dbg(1)");
fp = fopen("./nnndbg", "w");
if (!fp) {
perror("dbg(2)");
return -1;
}
}
DEBUG_FD = dup(fileno(fp));
fclose(fp);
if (DEBUG_FD == -1) {
perror("dbg(3)");
return -1;
}
return 0;
}
static void disabledbg()
{
close(DEBUG_FD);
}
#define DPRINTF_D(x) xprintf(DEBUG_FD, #x "=%d\n", x)
#define DPRINTF_U(x) xprintf(DEBUG_FD, #x "=%u\n", x)
#define DPRINTF_S(x) xprintf(DEBUG_FD, #x "=%s\n", x)
#define DPRINTF_P(x) xprintf(DEBUG_FD, #x "=%p\n", x)
#else
#define DPRINTF_D(x)
#define DPRINTF_U(x)
#define DPRINTF_S(x)
#define DPRINTF_P(x)
#endif /* DBGMODE */

236
src/nnn.c
View file

@ -94,76 +94,17 @@
#include <ftw.h> #include <ftw.h>
#include <wchar.h> #include <wchar.h>
#include "nnn.h"
#include "dbg.h"
/* Macro definitions */
#define VERSION "2.4"
#define GENERAL_INFO "BSD 2-Clause\nhttps://github.com/jarun/nnn"
#ifndef S_BLKSIZE #ifndef S_BLKSIZE
#define S_BLKSIZE 512 /* S_BLKSIZE is missing on Android NDK (Termux) */ #define S_BLKSIZE 512 /* S_BLKSIZE is missing on Android NDK (Termux) */
#endif #endif
#include "nnn.h"
#ifdef DBGMODE
static int DEBUG_FD;
static int
xprintf(int fd, const char *fmt, ...)
{
char buf[BUFSIZ];
int r;
va_list ap;
va_start(ap, fmt);
r = vsnprintf(buf, sizeof(buf), fmt, ap);
if (r > 0)
r = write(fd, buf, r);
va_end(ap);
return r;
}
static int
enabledbg()
{
FILE *fp = fopen("/tmp/nnndbg", "w");
if (!fp) {
perror("dbg(1)");
fp = fopen("./nnndbg", "w");
if (!fp) {
perror("dbg(2)");
return -1;
}
}
DEBUG_FD = dup(fileno(fp));
fclose(fp);
if (DEBUG_FD == -1) {
perror("dbg(3)");
return -1;
}
return 0;
}
static void
disabledbg()
{
close(DEBUG_FD);
}
#define DPRINTF_D(x) xprintf(DEBUG_FD, #x "=%d\n", x)
#define DPRINTF_U(x) xprintf(DEBUG_FD, #x "=%u\n", x)
#define DPRINTF_S(x) xprintf(DEBUG_FD, #x "=%s\n", x)
#define DPRINTF_P(x) xprintf(DEBUG_FD, #x "=%p\n", x)
#else
#define DPRINTF_D(x)
#define DPRINTF_U(x)
#define DPRINTF_S(x)
#define DPRINTF_P(x)
#endif /* DBGMODE */
/* Macro definitions */
#define VERSION "2.3"
#define GENERAL_INFO "BSD 2-Clause\nhttps://github.com/jarun/nnn"
#define LEN(x) (sizeof(x) / sizeof(*(x))) #define LEN(x) (sizeof(x) / sizeof(*(x)))
#undef MIN #undef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MIN(x, y) ((x) < (y) ? (x) : (y))
@ -227,30 +168,6 @@ disabledbg()
#define FREE 0 #define FREE 0
#define CAPACITY 1 #define CAPACITY 1
/* Function macros */
#define exitcurses() endwin()
#define clearprompt() printmsg("")
#define printwarn() printmsg(strerror(errno))
#define istopdir(path) ((path)[1] == '\0' && (path)[0] == '/')
#define copycurname() xstrlcpy(lastname, dents[cur].name, NAME_MAX + 1)
#define settimeout() timeout(1000)
#define cleartimeout() timeout(-1)
#define errexit() printerr(__LINE__)
#define setdirwatch() (cfg.filtermode ? (presel = FILTER) : (dir_changed = TRUE))
/* We don't care about the return value from strcmp() */
#define xstrcmp(a, b) (*(a) != *(b) ? -1 : strcmp((a), (b)))
/* A faster version of xisdigit */
#define xisdigit(c) ((unsigned int) (c) - '0' <= 9)
#define xerror() perror(xitoa(__LINE__))
#ifdef LINUX_INOTIFY
#define EVENT_SIZE (sizeof(struct inotify_event))
#define EVENT_BUF_LEN (1024 * (EVENT_SIZE + 16))
#elif defined(BSD_KQUEUE)
#define NUM_EVENT_SLOTS 1
#define NUM_EVENT_FDS 1
#endif
/* TYPE DEFINITIONS */ /* TYPE DEFINITIONS */
typedef unsigned long ulong; typedef unsigned long ulong;
typedef unsigned int uint; typedef unsigned int uint;
@ -339,6 +256,7 @@ static bm bookmark[BM_MAX];
static size_t g_tmpfplen; /* path to tmp files for copy without X, keybind help and file stats */ static size_t g_tmpfplen; /* path to tmp files for copy without X, keybind help and file stats */
static uchar g_crc; static uchar g_crc;
static uchar BLK_SHIFT = 9; static uchar BLK_SHIFT = 9;
static uchar opener_flag = F_NOTRACE;
static bool interrupted = FALSE; static bool interrupted = FALSE;
/* Retain old signal handlers */ /* Retain old signal handlers */
@ -359,18 +277,6 @@ static char g_cppath[PATH_MAX] __attribute__ ((aligned));
/* Buffer to store tmp file path */ /* Buffer to store tmp file path */
static char g_tmpfpath[HOME_LEN_MAX] __attribute__ ((aligned)); static char g_tmpfpath[HOME_LEN_MAX] __attribute__ ((aligned));
#ifdef LINUX_INOTIFY
static int inotify_fd, inotify_wd = -1;
static uint INOTIFY_MASK = IN_ATTRIB | IN_CREATE | IN_DELETE | IN_DELETE_SELF
| IN_MODIFY | IN_MOVE_SELF | IN_MOVED_FROM | IN_MOVED_TO;
#elif defined(BSD_KQUEUE)
static int kq, event_fd = -1;
static struct kevent events_to_monitor[NUM_EVENT_FDS];
static uint KQUEUE_FFLAGS = NOTE_DELETE | NOTE_EXTEND | NOTE_LINK
| NOTE_RENAME | NOTE_REVOKE | NOTE_WRITE;
static struct timespec gtimeout;
#endif
/* Replace-str for xargs on different platforms */ /* Replace-str for xargs on different platforms */
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__)
#define REPLACE_STR 'J' #define REPLACE_STR 'J'
@ -457,9 +363,10 @@ static const char * const messages[] = {
#define NNN_NO_AUTOSELECT 10 #define NNN_NO_AUTOSELECT 10
#define NNN_RESTRICT_NAV_OPEN 11 #define NNN_RESTRICT_NAV_OPEN 11
#define NNN_RESTRICT_0B 12 #define NNN_RESTRICT_0B 12
#define NNN_TRASH 13 #define NNN_OPENER_DETACH 13
#define NNN_TRASH 14
#ifdef __linux__ #ifdef __linux__
#define NNN_OPS_PROG 14 #define NNN_OPS_PROG 15
#endif #endif
static const char * const env_cfg[] = { static const char * const env_cfg[] = {
@ -476,6 +383,7 @@ static const char * const env_cfg[] = {
"NNN_NO_AUTOSELECT", "NNN_NO_AUTOSELECT",
"NNN_RESTRICT_NAV_OPEN", "NNN_RESTRICT_NAV_OPEN",
"NNN_RESTRICT_0B", "NNN_RESTRICT_0B",
"NNN_OPENER_DETACH",
"NNN_TRASH", "NNN_TRASH",
#ifdef __linux__ #ifdef __linux__
"NNN_OPS_PROG", "NNN_OPS_PROG",
@ -495,6 +403,40 @@ static const char * const envs[] = {
"PAGER", "PAGER",
}; };
/* Event handling */
#ifdef LINUX_INOTIFY
#define NUM_EVENT_SLOTS 16 /* Make room for 16 events */
#define EVENT_SIZE (sizeof(struct inotify_event))
#define EVENT_BUF_LEN (EVENT_SIZE * NUM_EVENT_SLOTS)
static int inotify_fd, inotify_wd = -1;
static uint INOTIFY_MASK = /* IN_ATTRIB | */ IN_CREATE | IN_DELETE | IN_DELETE_SELF
| IN_MODIFY | IN_MOVE_SELF | IN_MOVED_FROM | IN_MOVED_TO;
#elif defined(BSD_KQUEUE)
#define NUM_EVENT_SLOTS 1
#define NUM_EVENT_FDS 1
static int kq, event_fd = -1;
static struct kevent events_to_monitor[NUM_EVENT_FDS];
static uint KQUEUE_FFLAGS = NOTE_DELETE | NOTE_EXTEND | NOTE_LINK
| NOTE_RENAME | NOTE_REVOKE | NOTE_WRITE;
static struct timespec gtimeout;
#endif
/* Function macros */
#define exitcurses() endwin()
#define clearprompt() printmsg("")
#define printwarn() printmsg(strerror(errno))
#define istopdir(path) ((path)[1] == '\0' && (path)[0] == '/')
#define copycurname() xstrlcpy(lastname, dents[cur].name, NAME_MAX + 1)
#define settimeout() timeout(1000)
#define cleartimeout() timeout(-1)
#define errexit() printerr(__LINE__)
#define setdirwatch() (cfg.filtermode ? (presel = FILTER) : (dir_changed = TRUE))
/* We don't care about the return value from strcmp() */
#define xstrcmp(a, b) (*(a) != *(b) ? -1 : strcmp((a), (b)))
/* A faster version of xisdigit */
#define xisdigit(c) ((unsigned int) (c) - '0' <= 9)
#define xerror() perror(xitoa(__LINE__))
/* Forward declarations */ /* Forward declarations */
static void redraw(char *path); static void redraw(char *path);
static void spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag); static void spawn(char *file, char *arg1, char *arg2, const char *dir, uchar flag);
@ -949,7 +891,7 @@ static void resetcpind(void)
/* Initialize curses mode */ /* Initialize curses mode */
static bool initcurses(void) static bool initcurses(void)
{ {
int i; short i;
if (cfg.picker) { if (cfg.picker) {
if (!newterm(NULL, stderr, stdin)) { if (!newterm(NULL, stderr, stdin)) {
@ -1039,7 +981,8 @@ static void join(pid_t p, uchar flag)
if (!(flag & F_NOWAIT)) if (!(flag & F_NOWAIT))
/* wait for the child to exit */ /* wait for the child to exit */
while (waitpid(p, &status, 0) == -1); do {
} while (waitpid(p, &status, 0) == -1);
/* restore parent's signal handling */ /* restore parent's signal handling */
signal(SIGHUP, oldsighup); signal(SIGHUP, oldsighup);
@ -1068,9 +1011,10 @@ static void spawn(char *file, char *arg1, char *arg2, const char *dir, uchar fla
if (flag & F_MULTI) { if (flag & F_MULTI) {
size_t len = strlen(file) + 1; size_t len = strlen(file) + 1;
cmd = (char *)malloc(len); cmd = (char *)malloc(len);
if (!cmd) { if (!cmd) {
DPRINTF_S("spawn: malloc()!"); DPRINTF_S("malloc()!");
return; return;
} }
@ -1078,7 +1022,7 @@ static void spawn(char *file, char *arg1, char *arg2, const char *dir, uchar fla
status = parseargs(cmd, argv); status = parseargs(cmd, argv);
if (status == -1 || status > (EXEC_ARGS_MAX - 3)) { /* arg1, arg2 and last NULL */ if (status == -1 || status > (EXEC_ARGS_MAX - 3)) { /* arg1, arg2 and last NULL */
free(cmd); free(cmd);
DPRINTF_S("spawn: NULL or too many args"); DPRINTF_S("NULL or too many args");
return; return;
} }
@ -1444,8 +1388,12 @@ static int entrycmp(const void *va, const void *vb)
} }
/* Do the actual sorting */ /* Do the actual sorting */
if (cfg.mtimeorder) if (cfg.mtimeorder) {
return pb->t - pa->t; if (pb->t >= pa->t)
return (int)(pb->t - pa->t);
return -1;
}
if (cfg.sizeorder) { if (cfg.sizeorder) {
if (pb->size > pa->size) if (pb->size > pa->size)
@ -1475,7 +1423,10 @@ static int nextsel(int presel)
uint i; uint i;
const uint len = LEN(bindings); const uint len = LEN(bindings);
#ifdef LINUX_INOTIFY #ifdef LINUX_INOTIFY
static char inotify_buf[EVENT_BUF_LEN]; char *ptr;
struct inotify_event *event;
static char inotify_buf[EVENT_BUF_LEN]
__attribute__ ((aligned(__alignof__(struct inotify_event))));
#elif defined(BSD_KQUEUE) #elif defined(BSD_KQUEUE)
static struct kevent event_data[NUM_EVENT_SLOTS]; static struct kevent event_data[NUM_EVENT_SLOTS];
#endif #endif
@ -1502,14 +1453,32 @@ static int nextsel(int presel)
* Check for changes every odd second. * Check for changes every odd second.
*/ */
#ifdef LINUX_INOTIFY #ifdef LINUX_INOTIFY
if (!cfg.blkorder && inotify_wd >= 0 && idle & 1 if (!cfg.blkorder && inotify_wd >= 0 && (idle & 1)) {
&& read(inotify_fd, inotify_buf, EVENT_BUF_LEN) > 0) i = read(inotify_fd, inotify_buf, EVENT_BUF_LEN);
if (i > 0) {
for (ptr = inotify_buf; ptr < inotify_buf + i;
ptr += sizeof(struct inotify_event) + event->len) {
event = (struct inotify_event *) ptr;
DPRINTF_D(event->wd);
DPRINTF_D(event->mask);
if (!event->wd)
break;
if (event->mask & INOTIFY_MASK) {
c = CONTROL('L');
DPRINTF_S("issue refresh");
break;
}
}
DPRINTF_S("inotify read done");
}
}
#elif defined(BSD_KQUEUE) #elif defined(BSD_KQUEUE)
if (!cfg.blkorder && event_fd >= 0 && idle & 1 if (!cfg.blkorder && event_fd >= 0 && idle & 1
&& kevent(kq, events_to_monitor, NUM_EVENT_SLOTS, && kevent(kq, events_to_monitor, NUM_EVENT_SLOTS,
event_data, NUM_EVENT_FDS, &gtimeout) > 0) event_data, NUM_EVENT_FDS, &gtimeout) > 0)
#endif
c = CONTROL('L'); c = CONTROL('L');
#endif
} else } else
idle = 0; idle = 0;
@ -2349,9 +2318,9 @@ static size_t get_fs_info(const char *path, bool type)
return 0; return 0;
if (type == CAPACITY) if (type == CAPACITY)
return svb.f_blocks << ffs(svb.f_bsize >> 1); return svb.f_blocks << ffs((int)(svb.f_bsize >> 1));
return svb.f_bavail << ffs(svb.f_frsize >> 1); return svb.f_bavail << ffs((int)(svb.f_frsize >> 1));
} }
static bool show_mediainfo(const char *fpath, const char *arg) static bool show_mediainfo(const char *fpath, const char *arg)
@ -3073,7 +3042,7 @@ nochange:
} }
/* Invoke desktop opener as last resort */ /* Invoke desktop opener as last resort */
spawn(opener, newpath, NULL, NULL, F_NOWAIT | F_NOTRACE); spawn(opener, newpath, NULL, NULL, opener_flag);
continue; continue;
} }
default: default:
@ -3375,12 +3344,12 @@ nochange:
r = TRUE; r = TRUE;
switch (sel) { switch (sel) {
case SEL_MEDIA: case SEL_MEDIA: // fallthrough
r = show_mediainfo(newpath, NULL);
break;
case SEL_FMEDIA: case SEL_FMEDIA:
r = show_mediainfo(newpath, "-f"); tmp = (sel == SEL_FMEDIA) ? "-f" : NULL;
break; show_mediainfo(newpath, tmp);
setdirwatch();
goto nochange;
case SEL_ARCHIVELS: case SEL_ARCHIVELS:
r = handle_archive(newpath, "-l", path); r = handle_archive(newpath, "-l", path);
break; break;
@ -3492,7 +3461,7 @@ nochange:
g_crc = crc8fast((uchar *)dents, ndents * sizeof(struct entry)); g_crc = crc8fast((uchar *)dents, ndents * sizeof(struct entry));
copystartid = cur; copystartid = cur;
ncp = 0; ncp = 0;
mvprintw(xlines - 1, 0, "selection on"); mvprintw(xlines - 1, 0, "selection on\n");
xdelay(); xdelay();
continue; continue;
} }
@ -3923,7 +3892,8 @@ nochange:
fd = cfg.curctx; fd = cfg.curctx;
for (r = (fd + 1) & ~CTX_MAX; for (r = (fd + 1) & ~CTX_MAX;
(r != fd) && !g_ctx[r].c_cfg.ctxactive; (r != fd) && !g_ctx[r].c_cfg.ctxactive;
r = ((r + 1) & ~CTX_MAX)); r = ((r + 1) & ~CTX_MAX)) {
};
if (r != fd) { if (r != fd) {
g_ctx[fd].c_cfg.ctxactive = 0; g_ctx[fd].c_cfg.ctxactive = 0;
@ -3961,7 +3931,7 @@ nochange:
static void usage(void) static void usage(void)
{ {
fprintf(stdout, fprintf(stdout,
"%s: nnn [-b key] [-C] [-d] [-e] [-i] [-l] [-n]\n" "%s: nnn [-b key] [-d] [-e] [-i] [-l] [-n]\n"
" [-p file] [-s] [-S] [-v] [-w] [-h] [PATH]\n\n" " [-p file] [-s] [-S] [-v] [-w] [-h] [PATH]\n\n"
"The missing terminal file manager for X.\n\n" "The missing terminal file manager for X.\n\n"
"positional args:\n" "positional args:\n"
@ -3969,7 +3939,6 @@ static void usage(void)
"optional args:\n" "optional args:\n"
" -b key open bookmark key\n" " -b key open bookmark key\n"
" -d show hidden files\n" " -d show hidden files\n"
" -C disable directory color\n"
" -e use exiftool for media info\n" " -e use exiftool for media info\n"
" -i nav-as-you-type mode\n" " -i nav-as-you-type mode\n"
" -l light mode\n" " -l light mode\n"
@ -3978,7 +3947,7 @@ static void usage(void)
" -s string filters [default: regex]\n" " -s string filters [default: regex]\n"
" -S du mode\n" " -S du mode\n"
" -v show version\n" " -v show version\n"
" -w wild mode\n" " -w wild load\n"
" -h show help\n\n" " -h show help\n\n"
"v%s\n%s\n", __func__, VERSION, GENERAL_INFO); "v%s\n%s\n", __func__, VERSION, GENERAL_INFO);
} }
@ -4071,6 +4040,9 @@ int main(int argc, char *argv[])
++opt; ++opt;
} }
home = getenv("HOME");
DPRINTF_S(home);
/* Parse bookmarks string */ /* Parse bookmarks string */
if (!parsebmstr()) { if (!parsebmstr()) {
fprintf(stderr, "%s\n", env_cfg[NNN_BMS]); fprintf(stderr, "%s\n", env_cfg[NNN_BMS]);
@ -4134,6 +4106,8 @@ int main(int argc, char *argv[])
/* Get custom opener, if set */ /* Get custom opener, if set */
opener = xgetenv(env_cfg[NNN_OPENER], utils[OPENER]); opener = xgetenv(env_cfg[NNN_OPENER], utils[OPENER]);
if (getenv(env_cfg[NNN_OPENER_DETACH]))
opener_flag |= F_NOWAIT;
/* Set nnn nesting level, idletimeout used as tmp var */ /* Set nnn nesting level, idletimeout used as tmp var */
idletimeout = xatoi(getenv(env_cfg[NNNLVL])); idletimeout = xatoi(getenv(env_cfg[NNNLVL]));
@ -4143,9 +4117,6 @@ int main(int argc, char *argv[])
idletimeout = xatoi(getenv(env_cfg[NNN_IDLE_TIMEOUT])); idletimeout = xatoi(getenv(env_cfg[NNN_IDLE_TIMEOUT]));
DPRINTF_U(idletimeout); DPRINTF_U(idletimeout);
home = getenv("HOME");
DPRINTF_S(home);
if (getenv(env_cfg[NNN_TRASH])) if (getenv(env_cfg[NNN_TRASH]))
cfg.trash = 1; cfg.trash = 1;
@ -4154,8 +4125,11 @@ int main(int argc, char *argv[])
g_tmpfplen = xstrlcpy(g_tmpfpath, home, HOME_LEN_MAX); g_tmpfplen = xstrlcpy(g_tmpfpath, home, HOME_LEN_MAX);
else if (xdiraccess("/tmp")) else if (xdiraccess("/tmp"))
g_tmpfplen = xstrlcpy(g_tmpfpath, "/tmp", HOME_LEN_MAX); g_tmpfplen = xstrlcpy(g_tmpfpath, "/tmp", HOME_LEN_MAX);
else if ((copier = getenv("TMPDIR")) != NULL) else {
copier = getenv("TMPDIR");
if (copier != NULL)
g_tmpfplen = xstrlcpy(g_tmpfpath, copier, HOME_LEN_MAX); g_tmpfplen = xstrlcpy(g_tmpfpath, copier, HOME_LEN_MAX);
}
if (!cfg.picker && g_tmpfplen) { if (!cfg.picker && g_tmpfplen) {
xstrlcpy(g_cppath, g_tmpfpath, PATH_MAX); xstrlcpy(g_cppath, g_tmpfpath, PATH_MAX);

View file

@ -185,7 +185,7 @@ static struct key bindings[] = {
{ CONTROL('J'), SEL_BSIZE }, { CONTROL('J'), SEL_BSIZE },
/* Toggle sort by time */ /* Toggle sort by time */
{ 't', SEL_MTIME }, { 't', SEL_MTIME },
/* Wild mode */ /* Wild load */
{ CONTROL('W'), SEL_WILD }, { CONTROL('W'), SEL_WILD },
/* Redraw window */ /* Redraw window */
{ CONTROL('L'), SEL_REDRAW }, { CONTROL('L'), SEL_REDRAW },

View file

@ -1,12 +1,16 @@
#### List of scripts | Script (a-z) | Description |
| Script | Description |
| --- | --- | | --- | --- |
| copier.sh | Copy selection to clipboard | | copier | Copy selection to clipboard |
| edit.sh | Fuzzy find a file in directory subtree with fzy and edit in vim | | edit | Fuzzy find a file in directory subtree with fzy and edit in vim |
| fzy.sh | Fuzzy find a file in directory subtree with fzy and open using xdg-open | | fzy | Fuzzy find a file in directory subtree with fzy and open using xdg-open |
| imgur.sh | Upload an image file to imgur | | hexview | view a file in hex; needs xxd and $PAGER |
| nlaunch | drop-down app launcher (needs fzy), drop in `$PATH`; fallback regular prompt | | imgresize | Resize images in directory to screen resolution (needs [imgp](https://github.com/jarun/imgp)) |
| picker.sh | Pick files and pipe the newline-separated list to another utility | | imgur | Upload an image file to imgur |
| sxiv.sh | Open images in current directory in sxiv | | kdeconnect | Send selected files to Android device using kdeconnect-cli |
| upgrade.sh | Check and update to latest version of nnn manually on Debian 9 Stretch | | ndiff | File and directory diff for selection using vimdiff |
| nlaunch | Drop-down independent app launcher (needs fzy), drop in `$PATH`; fallback regular prompt |
| paste | Paste contents of current (text) file to paste.ubuntu.com (needs [pastebinit](https://launchpad.net/pastebinit)) |
| picker | Pick files and pipe the newline-separated list to another utility |
| sxiv | Open images in current directory in sxiv |
| transfer | Upload current file to transfer.sh |
| upgrade | Check and update to latest version of nnn manually on Debian 9 Stretch |

View file

@ -2,7 +2,7 @@
# Description: Copy selection to clipboard # Description: Copy selection to clipboard
# #
# Shell: generic # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana
# Linux # Linux

View file

@ -2,11 +2,7 @@
# Description: Fuzzy find a file in directory subtree with fzy and edit in vim # Description: Fuzzy find a file in directory subtree with fzy and edit in vim
# #
# Shell: generic # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana
# bash, zsh vim `find -type f | fzy`
vim $(find -type f | fzy)
# fish
# vim (find -type f | fzy)

View file

@ -2,11 +2,7 @@
# Description: Fuzzy find a file in directory subtree with fzy and open using xdg-open # Description: Fuzzy find a file in directory subtree with fzy and open using xdg-open
# #
# Shell: generic # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana
# bash, zsh xdg-open `find -type f | fzy` >/dev/null 2>&1
xdg-open $(find -type f | fzy) >/dev/null 2>&1
# fish
# xdg-open (find -type f | fzy) >/dev/null 2>&1

11
user-scripts/hexview Executable file
View file

@ -0,0 +1,11 @@
#!/usr/bin/env sh
# Description: View a file in hex
# Requires: xxd and $PAGER
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
if ! [ -z "$1" ]; then
xxd "$1" | "$PAGER"
fi

32
user-scripts/imgresize Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env sh
# Description: Resize images in a directory to screen resolution with imgp
# imgp homepage: https://github.com/jarun/imgp
#
# Notes:
# 1. Set res if you don't want to be prompted for desktop resolution every time
# 2. minsize is set to 1MB by default, adjust it if you want
# 3. imgp options used:
# a - adaptive mode
# c - convert PNG to JPG
# k - skip images matching specified hres/vres
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
# set resolution (e.g. 1920x1080)
res=
# set minimum image size (in bytes) to resize (default: 1MB)
minsize=1048576
if [ -z "$res" ]; then
echo -n "desktop resolution (hxv): "
read res
fi
if ! [ -z "$res" ]; then
if ! [ -z "$minsize" ]; then
imgp -ackx "$res" -s "$minsize"
fi
fi

View file

@ -3,6 +3,7 @@
# Description: Send the selected files to your Android device using kdeconnect-cli. You must have installed and configured kdeconnect both on the Android device and on the PC. # Description: Send the selected files to your Android device using kdeconnect-cli. You must have installed and configured kdeconnect both on the Android device and on the PC.
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: juacq97 # Author: juacq97
id=$(kdeconnect-cli -a --id-only | awk '{print $1}') id=$(kdeconnect-cli -a --id-only | awk '{print $1}')

8
user-scripts/ndiff Executable file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env sh
# Description: File and directory diff using vimdiff
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
vimdiff $(cat ~/.nnncp | tr '\0' '\n')

View file

@ -1,7 +1,8 @@
#!/usr/bin/env sh #!/usr/bin/env sh
# Description: Fuzzy find executables in $PATH and launch an application # Description: Fuzzy find executables in $PATH and launch an application.
# stdin, stdout, stderr are suppressed so CLI utilities exit silently # stdin, stdout, stderr are suppressed so CLI utilities exit silently.
# Works as an independent app launcher.
# #
# Shell: POSIX compliant # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana

13
user-scripts/paste Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env sh
# Description: Paste contents of a text a file to paste.ubuntu.com using pastebinit
#
# pastebinit: https://launchpad.net/pastebinit
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
if ! [ -z "$1" ]; then
pastebinit "$1"
read input
fi

View file

@ -2,7 +2,7 @@
# Description: Pick files and pipe the newline-separated list to another utility # Description: Pick files and pipe the newline-separated list to another utility
# #
# Shell: generic # Shell: POSIX compliant
# Author: Arun Prakash Jana # Author: Arun Prakash Jana
# #
# Usage: # Usage:

16
user-scripts/transfer Executable file
View file

@ -0,0 +1,16 @@
#!/usr/bin/env sh
# Description: Upload a file to transfer.sh
#
# Shell: POSIX compliant
# Author: Arun Prakash Jana
if ! [ -z "$1" ]; then
# Upload the file, show the download link and wait till user presses any key
curl -s --upload-file "$1" https://transfer.sh/`basename "$1"`
echo
read input
# To write download link to "$1".loc and exit
# curl -s --upload-file "$1" https://transfer.sh/`basename "$1"` -o `basename "$1"`.loc
fi

View file

@ -18,7 +18,7 @@ fi
wget "https://github.com/jarun/nnn/releases/download/v$new/nnn_$new-1_debian9.amd64.deb" wget "https://github.com/jarun/nnn/releases/download/v$new/nnn_$new-1_debian9.amd64.deb"
# install it # install it
dpkg -i nnn_$new-1_debian9.amd64.deb sudo dpkg -i nnn_$new-1_debian9.amd64.deb
# remove the file # remove the file
rm -rf nnn_$new-1_debian9.amd64.deb rm -rf nnn_$new-1_debian9.amd64.deb