SEL_CDBEGIN,
SEL_CDLAST,
SEL_CDBM,
+ SEL_MARK,
+ SEL_VISIT,
SEL_TOGGLEDOT,
SEL_DETAIL,
SEL_STATS,
{ '-', SEL_CDLAST, "", "" },
/* Change dir using bookmark */
{ 'b', SEL_CDBM, "", "" },
+ /* Mark a path to visit later */
+ { CONTROL('B'), SEL_MARK, "", "" },
+ /* Visit marked directory */
+ { CONTROL('V'), SEL_VISIT, "", "" },
/* Toggle hide .dot files */
{ '.', SEL_TOGGLEDOT, "", "" },
/* Detailed listing */
{ 'S', SEL_BSIZE, "", "" },
/* Toggle sort by time */
{ 't', SEL_MTIME, "", "" },
+ /* Redraw window */
{ CONTROL('L'), SEL_REDRAW, "", "" },
{ KEY_F(2), SEL_REDRAW, "", "" },
/* Copy currently selected file path */
^/ | Open desktop search tool\n\
. | Toggle hide .dot files\n\
b | Show bookmark key prompt\n\
+ ^B | Mark current dir\n\
+ ^V | Visit marked dir\n\
c | Show change dir prompt\n\
d | Toggle detail view\n\
D | Show current file details\n\
static void
browse(char *ipath, char *ifilter)
{
- char path[PATH_MAX], oldpath[PATH_MAX], newpath[PATH_MAX];
- char lastdir[PATH_MAX];
- char fltr[LINE_MAX];
+ static char path[PATH_MAX], oldpath[PATH_MAX], newpath[PATH_MAX], lastdir[PATH_MAX], mark[PATH_MAX];
+ static char fltr[LINE_MAX];
char *dir, *tmp, *run, *env, *tgt = NULL;
struct stat sb;
int r, fd, presel;
xstrlcpy(path, ipath, PATH_MAX);
xstrlcpy(fltr, ifilter, LINE_MAX);
- oldpath[0] = '\0';
- newpath[0] = '\0';
- lastdir[0] = '\0'; /* Can't move back from initial directory */
+ oldpath[0] = newpath[0] = lastdir[0] = mark[0] = '\0';
if (cfg.filtermode)
presel = FILTER;
presel = FILTER;
tgt = NULL;
goto begin;
- case SEL_CDLAST:
- if (lastdir[0] == '\0') {
- printmsg("Hit end of history...");
+ case SEL_CDLAST: // fallthrough
+ case SEL_VISIT:
+ if (sel == SEL_VISIT) {
+ if (xstrcmp(mark, path) == 0)
+ break;
+
+ tmp = mark;
+ } else
+ tmp = lastdir;
+
+ if (tmp[0] == '\0') {
+ printmsg("Not set...");
goto nochange;
}
- if (access(lastdir, R_OK) == -1) {
+ if (access(tmp, R_OK) == -1) {
printwarn();
goto nochange;
}
- xstrlcpy(newpath, lastdir, PATH_MAX);
+ xstrlcpy(newpath, tmp, PATH_MAX);
xstrlcpy(lastdir, path, PATH_MAX);
xstrlcpy(path, newpath, PATH_MAX);
oldpath[0] = '\0';
if (cfg.filtermode)
presel = FILTER;
goto begin;
+ case SEL_MARK:
+ xstrlcpy(mark, path, PATH_MAX);
+ printmsg(mark);
+ goto nochange;
case SEL_TOGGLEDOT:
cfg.showhidden ^= 1;
initfilter(cfg.showhidden, &ifilter);
int
main(int argc, char *argv[])
{
- char cwd[PATH_MAX], *ipath;
- char *ifilter, *bmstr;
+ static char cwd[PATH_MAX];
+ char *ipath, *ifilter, *bmstr;
int opt;
/* Confirm we are in a terminal */