README.md | 7 +++++++ nnn.1 | 7 +++++++ src/nnn.c | 21 ++++++++++++++------- diff --git a/README.md b/README.md index a9d2148a9cc945c652e2e2babd2514f48ff6c8ba..81fc3b164c0e214de4537d21f3582a21b4c196e3 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,7 @@ | --- | --- | | `NNN_BMS='d:~/Documents;D:~/Docs archive/'` | specify bookmarks (max 10) | | `NNN_USE_EDITOR=1` | open text files in `$VISUAL` (else `$EDITOR`, fallback vi) | | `NNN_CONTEXT_COLORS='1234'` | specify per context color [default: '4444' (all blue)] | +| `NNN_SSHFS_OPTS='sshfs -o reconnect,idmap=user'` | specify SSHFS options | | `NNN_NOTE=/home/user/Dropbox/notes` | path to note file [default: none] | | `NNN_OPENER=mimeopen` | custom file opener | | `NNN_IDLE_TIMEOUT=300` | idle seconds before locking terminal [default: disabled] | @@ -398,6 +399,12 @@ Port 8022 ``` The above host `phone` will be mounted at `${XDG_CONFIG_HOME:-$HOME/.config}/nnn/phone`. `nnn` creates the directory `phone` if it doesn't exist. + +If you need to pass options to the `sshfs` command, you can do so: + + export NNN_SSHFS_OPTS='sshfs -o reconnect,idmap=user,cache_timeout=3600' + +The options must be preceded by `sshfs` and comma-separated without any space between them. Notes: diff --git a/nnn.1 b/nnn.1 index 9de15022ae7a6f6e41508ebc361e225799eacfc0..ad525074579c0e0d9774bd96c95f50e8fb133046 100644 --- a/nnn.1 +++ b/nnn.1 @@ -157,6 +157,13 @@ codes: 0-black, 1-red, 2-green, 3-yellow, 4-blue (default), 5-magenta, 6-cyan, 7-white .Ed .Pp +\fBNNN_SSHFS_OPTS:\fR Pass additional options to sshfs command: +.Bd -literal + export NNN_SSHFS_OPTS='sshfs -o reconnect,idmap=user,cache_timeout=3600' + + NOTE: The options must be preceded by `sshfs` and comma-separated without any space between them. +.Ed +.Pp \fBNNN_IDLE_TIMEOUT:\fR set idle timeout (in seconds) to invoke terminal locker (default: disabled). .Pp \fBNNN_COPIER:\fR system clipboard copier script. The project page has some sample copier scripts. diff --git a/src/nnn.c b/src/nnn.c index 921883848643a6e20c9afdf557f61583a4351e36..b00b90249c4b849592fde0f1084d624a1f69de31 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -2569,8 +2569,14 @@ } static bool sshfs_mount(char *path, char *newpath, int *presel) { + uchar flag = F_NORMAL; int r; - char *tmp; + char *tmp, *env, *cmd = "sshfs"; + + if (!getutil(cmd)) { + printwait("sshfs missing", presel); + return FALSE; + } tmp = xreadline(NULL, "host: "); if (!tmp[0]) @@ -2583,18 +2589,19 @@ printwait(strerror(errno), presel); return FALSE; } - if (!getutil("sshfs")) { - printwait("sshfs missing", presel); - return FALSE; - } - /* Convert "Host" to "Host:" */ r = strlen(tmp); tmp[r] = ':'; tmp[r + 1] = '\0'; + env = getenv("NNN_SSHFS_OPTS"); + if (env) + flag |= F_MULTI; + else + env = cmd; + /* Connect to remote */ - if (spawn("sshfs", tmp, newpath, NULL, F_NORMAL)) { + if (spawn(env, tmp, newpath, NULL, flag)) { printwait("mount failed", presel); return FALSE; }