mirror of
https://github.com/jarun/nnn.git
synced 2025-01-15 21:36:42 +00:00
Fix #1369: open target of symlinked bookmark
This commit is contained in:
parent
ec076f5886
commit
8d83af811f
13
nnn.1
13
nnn.1
|
@ -351,10 +351,15 @@ There are 2 ways (can be used together) to manage bookmarks.
|
||||||
(1) Bookmark keys: See \fINNN_BMS\fR under \fIENVIORNMENT\fR section on how to
|
(1) Bookmark keys: See \fINNN_BMS\fR under \fIENVIORNMENT\fR section on how to
|
||||||
set bookmark keys.
|
set bookmark keys.
|
||||||
.Pp
|
.Pp
|
||||||
(2) Symlinked bookmarks: Symlinked bookmarks can be created at runtime
|
(2) Symlinked bookmarks: A symlinked bookmark to the current directory can be
|
||||||
with the \fIB\fR key. They can also be manually created by adding symlinks
|
created with the \fIB\fR key.
|
||||||
to bookmarked locations under the bookmarks directory in the nnn config
|
Add prefix \fBn_\fR to the names to open the targets instead of the symlinks.
|
||||||
directory (~/.config/nnn/bookmarks).
|
|
||||||
|
Symlinks can also be created manually under the "bookmarks" directory in
|
||||||
|
the nnn config directory (~/.config/nnn/bookmarks).
|
||||||
|
|
||||||
|
Pressing 'Enter' at the bookmarks prompt takes to this directory.
|
||||||
|
If \fINNN_BMS\fR is not set, it happens directly on select bookmark key.
|
||||||
.Pp
|
.Pp
|
||||||
Pressing \fIb\fR will list all the bookmark keys set in NNN_BMS. Pressing
|
Pressing \fIb\fR will list all the bookmark keys set in NNN_BMS. Pressing
|
||||||
\fIEnter\fR at this prompt will take to the symlink bookmark directory, if
|
\fIEnter\fR at this prompt will take to the symlink bookmark directory, if
|
||||||
|
|
14
src/nnn.c
14
src/nnn.c
|
@ -178,6 +178,8 @@
|
||||||
#define MSGWAIT '$'
|
#define MSGWAIT '$'
|
||||||
#define SELECT ' '
|
#define SELECT ' '
|
||||||
#define PROMPT ">>> "
|
#define PROMPT ">>> "
|
||||||
|
#define BM_PREFIX "n_"
|
||||||
|
#define BM_PREFIX_LEN (sizeof BM_PREFIX - 1)
|
||||||
#define REGEX_MAX 48
|
#define REGEX_MAX 48
|
||||||
#define ENTRY_INCR 64 /* Number of dir 'entry' structures to allocate per shot */
|
#define ENTRY_INCR 64 /* Number of dir 'entry' structures to allocate per shot */
|
||||||
#define NAMEBUF_INCR 0x800 /* 64 dir entries at once, avg. 32 chars per file name = 64*32B = 2KB */
|
#define NAMEBUF_INCR 0x800 /* 64 dir entries at once, avg. 32 chars per file name = 64*32B = 2KB */
|
||||||
|
@ -638,6 +640,7 @@ static char * const utils[] = {
|
||||||
#define MSG_INVALID_KEY 40
|
#define MSG_INVALID_KEY 40
|
||||||
#define MSG_NOCHANGE 41
|
#define MSG_NOCHANGE 41
|
||||||
#define MSG_DIR_CHANGED 42
|
#define MSG_DIR_CHANGED 42
|
||||||
|
#define MSG_BM_NAME 43
|
||||||
|
|
||||||
static const char * const messages[] = {
|
static const char * const messages[] = {
|
||||||
"",
|
"",
|
||||||
|
@ -672,7 +675,7 @@ static const char * const messages[] = {
|
||||||
"too few cols!",
|
"too few cols!",
|
||||||
"'s'shfs / 'r'clone?",
|
"'s'shfs / 'r'clone?",
|
||||||
"refresh if slow",
|
"refresh if slow",
|
||||||
"app name: ",
|
"app: ",
|
||||||
"'o'pen / e'x'tract / 'l's / 'm'nt?",
|
"'o'pen / e'x'tract / 'l's / 'm'nt?",
|
||||||
"keys:",
|
"keys:",
|
||||||
"invalid regex",
|
"invalid regex",
|
||||||
|
@ -683,6 +686,7 @@ static const char * const messages[] = {
|
||||||
"invalid key",
|
"invalid key",
|
||||||
"unchanged",
|
"unchanged",
|
||||||
"dir changed, range sel off",
|
"dir changed, range sel off",
|
||||||
|
"name (prefix n_ to identify): ",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Supported configuration environment variables */
|
/* Supported configuration environment variables */
|
||||||
|
@ -4998,7 +5002,7 @@ static void add_bookmark(char *path, char *newpath, int *presel)
|
||||||
{
|
{
|
||||||
char *dir = xbasename(path);
|
char *dir = xbasename(path);
|
||||||
|
|
||||||
dir = xreadline(dir[0] ? dir : NULL, "name: ");
|
dir = xreadline(dir[0] ? dir : NULL, messages[MSG_BM_NAME]);
|
||||||
if (dir && *dir) {
|
if (dir && *dir) {
|
||||||
size_t r = mkpath(cfgpath, toks[TOK_BM], newpath);
|
size_t r = mkpath(cfgpath, toks[TOK_BM], newpath);
|
||||||
|
|
||||||
|
@ -6902,7 +6906,11 @@ nochange:
|
||||||
}
|
}
|
||||||
|
|
||||||
pent = &pdents[cur];
|
pent = &pdents[cur];
|
||||||
mkpath(path, pent->name, newpath);
|
r = FALSE;
|
||||||
|
/* Check if it's a symlinked boookmark */
|
||||||
|
(S_ISLNK(pent->mode) && is_prefix(pent->name, BM_PREFIX, BM_PREFIX_LEN))
|
||||||
|
? (realpath(pent->name, newpath) && xstrsncpy(path, lastdir, PATH_MAX))
|
||||||
|
: mkpath(path, pent->name, newpath);
|
||||||
DPRINTF_S(newpath);
|
DPRINTF_S(newpath);
|
||||||
|
|
||||||
/* Visit directory */
|
/* Visit directory */
|
||||||
|
|
Loading…
Reference in a new issue