aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--misc/auto-completion/bash/nnn-completion.bash30
-rw-r--r--src/nnn.c66
3 files changed, 62 insertions, 43 deletions
diff --git a/README.md b/README.md
index b901d64..30c780b 100644
--- a/README.md
+++ b/README.md
@@ -26,11 +26,16 @@ It runs on Linux, macOS, Raspberry Pi, BSD, Cygwin, Linux subsystem for Windows
`nnn` works seamlessly with DEs and GUI utilities. It's nearly zero-config (with sensible defaults) and can be setup in less than 5 minutes. **[Quickstart](#quickstart)** and see how `nnn` simplifies workflows.
+Demo videos:
+
+- [`nnn` on Termux (Android)](https://vimeo.com/346719001)
+- [features overview](https://www.youtube.com/watch?v=U2n5aGqou9E)
+
<p align="center">
-<a href="https://www.youtube.com/watch?v=U2n5aGqou9E"><img src="https://i.imgur.com/onpq3vP.png" alt="Click to watch video"/></a>
+<a><img src="https://i.imgur.com/onpq3vP.png" /></a>
</p>
-<p align="center"><i>3 modes of nnn (light with filter, detail, du analyzer) with memory usage. Click for a demo video.</i></a></p>
+<p align="center"><i>3 modes of nnn (light with filter, detail, du analyzer) with memory usage</i></a></p>
#### TABLE OF CONTENTS
diff --git a/misc/auto-completion/bash/nnn-completion.bash b/misc/auto-completion/bash/nnn-completion.bash
index 4c81e77..a0dcd30 100644
--- a/misc/auto-completion/bash/nnn-completion.bash
+++ b/misc/auto-completion/bash/nnn-completion.bash
@@ -9,7 +9,7 @@ _nnn () {
COMPREPLY=()
local IFS=$' \n'
local cur=$2 prev=$3
- local -a opts opts_with_args
+ local -a opts
opts=(
-b
-d
@@ -23,22 +23,16 @@ _nnn () {
-v
-w
)
- opts_with_arg=(
- -b
- -p
- )
-
- # Do not complete non option names
- [[ $cur == -* ]] || return 1
-
- # Do not complete when the previous arg is an option expecting an argument
- for opt in "${opts_with_arg[@]}"; do
- [[ $opt == $prev ]] && return 1
- done
-
- # Complete option names
- COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
- return 0
+ if [[ $prev == -b ]]; then
+ local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
+ COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
+ elif [[ $prev == -p ]]; then
+ COMPREPLY=( $(compgen -f -d -- "$cur") )
+ elif [[ $cur == -* ]]; then
+ COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
+ else
+ COMPREPLY=( $(compgen -f -d -- "$cur") )
+ fi
}
-complete -F _nnn nnn
+complete -o filenames -F _nnn nnn
diff --git a/src/nnn.c b/src/nnn.c
index 881b349..5f06843 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -133,7 +133,7 @@
#define DOT_FILTER_LEN 7
#define ASCII_MAX 128
#define EXEC_ARGS_MAX 8
-#define SCROLLOFF 5
+#define SCROLLOFF 3
#define LONG_SIZE sizeof(ulong)
/* Program return codes */
@@ -145,14 +145,13 @@
#define FILE_COPIED 0x10
/* Macros to define process spawn behaviour as flags */
-#define F_NONE 0x00 /* no flag set */
-#define F_MULTI 0x01 /* first arg can be combination of args; to be used with F_NORMAL */
-#define F_NOWAIT 0x02 /* don't wait for child process (e.g. file manager) */
-#define F_NOTRACE 0x04 /* suppress stdout and strerr (no traces) */
-#define F_NORMAL 0x08 /* spawn child process in non-curses regular CLI mode */
-#define F_CMD 0x10 /* run command - show results before exit (must have F_NORMAL) */
-
-#define F_CLI (F_NORMAL | F_MULTI)
+#define F_NONE 0x00 /* no flag set */
+#define F_MULTI 0x01 /* first arg can be combination of args; to be used with F_NORMAL */
+#define F_NOWAIT 0x02 /* don't wait for child process (e.g. file manager) */
+#define F_NOTRACE 0x04 /* suppress stdout and strerr (no traces) */
+#define F_NORMAL 0x08 /* spawn child process in non-curses regular CLI mode */
+#define F_CMD 0x10 /* run command - show results before exit (must have F_NORMAL) */
+#define F_CLI (F_NORMAL | F_MULTI)
/* CRC8 macros */
#define UCHAR_BIT_WIDTH (sizeof(unsigned char) << 3)
@@ -165,14 +164,14 @@
* states: S_N: normal, S_I: comparing integral part, S_F: comparing
* fractional parts, S_Z: idem but with leading Zeroes only
*/
-#define S_N 0x0
-#define S_I 0x3
-#define S_F 0x6
-#define S_Z 0x9
+#define S_N 0x0
+#define S_I 0x3
+#define S_F 0x6
+#define S_Z 0x9
/* result_type: VCMP: return diff; VLEN: compare using len_diff/diff */
-#define VCMP 2
-#define VLEN 3
+#define VCMP 2
+#define VLEN 3
/* Volume info */
#define FREE 0
@@ -666,7 +665,6 @@ static size_t xstrlcpy(char *dest, const char *src, size_t n)
size_t len = strlen(src) + 1, blocks;
const uint _WSHIFT = (LONG_SIZE == 8) ? 3 : 2;
-
if (n > len)
n = len;
else if (len > n)
@@ -893,6 +891,7 @@ static bool initcurses(void)
//intrflush(stdscr, FALSE);
keypad(stdscr, TRUE);
mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON2_CLICKED, NULL);
+ mouseinterval(400);
curs_set(FALSE); /* Hide cursor */
start_color();
use_default_colors();
@@ -2133,6 +2132,7 @@ static char *coolsize(off_t size)
const char * const U = "BKMGTPEZY";
static char size_buf[12]; /* Buffer to hold human readable size */
off_t rem = 0;
+ size_t ret;
int i = 0;
while (size >= 1024) {
@@ -2177,10 +2177,28 @@ static char *coolsize(off_t size)
rem /= 10;
}
- if (i > 0 && i < 6)
- snprintf(size_buf, 12, "%u.%0*u%c", (uint)size, i & 0b11, (uint)rem, U[i]);
- else
- snprintf(size_buf, 12, "%u%c", (uint)size, U[i]);
+ if (i > 0 && i < 6 && rem) {
+ ret = xstrlcpy(size_buf, xitoa(size), 11);
+ size_buf[ret - 1] = '.';
+
+ char *frac = xitoa(rem);
+ size_t toprint = i > 3 ? 3 : i;
+ size_t len = strlen(frac);
+
+ if (len < toprint) {
+ size_buf[ret] = size_buf[ret + 1] = size_buf[ret + 2] = '0';
+ xstrlcpy(size_buf + ret + (toprint - len), frac, (toprint - len) + 1);
+ } else
+ xstrlcpy(size_buf + ret, frac, toprint + 1);
+
+ ret += toprint;
+ } else {
+ ret = xstrlcpy(size_buf, size ? xitoa(size) : "0", 10);
+ --ret;
+ }
+
+ size_buf[ret] = U[i];
+ size_buf[ret + 1] = '\0';
return size_buf;
}
@@ -2401,7 +2419,9 @@ static char *get_output(char *buf, const size_t bytes, const char *file,
static bool getutil(const char *util)
{
- if (!get_output(g_buf, CMD_LEN_MAX, "which", util, NULL, FALSE))
+ char buf[8];
+
+ if (!get_output(buf, 8, "which", util, NULL, FALSE))
return FALSE;
return TRUE;
@@ -2421,9 +2441,9 @@ static bool show_stats(const char *fpath, const char *fname, const struct stat *
if (fd == -1)
return FALSE;
- r = xstrlcpy(g_buf, "stat \'", PATH_MAX);
+ r = xstrlcpy(g_buf, "stat \"", PATH_MAX);
r += xstrlcpy(g_buf + r - 1, fpath, PATH_MAX);
- g_buf[r - 2] = '\'';
+ g_buf[r - 2] = '\"';
g_buf[r - 1] = '\0';
DPRINTF_S(g_buf);