From e1e34bc6ed9aba0d9e88b376007dfe47c9c7a5e4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 12 Sep 2019 18:41:15 -0700 Subject: Replaced marks system with something a little more elegant using symbolic links in ~/.config/bb/marks/. The new version is a little more flexible (arbitrary mark names), persistent across bb sessions, and uses a bit less code. --- config.def.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'config.def.h') diff --git a/config.def.h b/config.def.h index 4b035c9..167869a 100644 --- a/config.def.h +++ b/config.def.h @@ -34,8 +34,6 @@ dotfiles:[01] Whether dotfiles are visible goto: Move the cursor to (changing directory if needed) interleave:[01] Whether or not directories should be interleaved with files in the display - jump: Jump to the mark associated with - mark:[=] Associate with (or current dir, if blank) move: Move the cursor a numeric amount quit Quit bb refresh Refresh the file listing @@ -149,8 +147,11 @@ const column_t columns[128] = { // This is a list of commands that runs when `bb` launches: const char *startupcmds[] = { // Set some default marks: - "+mark:0", "+mark:~=~", "+mark:h=~", "+mark:/=/", "+mark:c=~/.config", - "+mark:l=~/.local", "+mark:s=", + "mkdir -p ~/.config/bb/marks", + "ln -sfT ~ ~/.config/bb/marks/home", + "ln -sfT / ~/.config/bb/marks/root", + "ln -sfT ~/.config ~/.config/bb/marks/config", + "ln -sfT ~/.local ~/.config/bb/marks/local", // Default column and sorting options: "+sort:+n", "+col:*smpn", "+..", NULL, // NULL-terminated array @@ -207,8 +208,12 @@ binding_t bindings[] = { {{':'}, "sh -c \"$(" ASKECHO(":", "") ")\" -- \"$@\"; " PAUSE "; bb +refresh", B("Run")" a command"}, {{'>'}, "tput rmcup >/dev/tty; $SHELL; bb +r", "Open a "B("shell")}, - {{'m'}, "read -n1 -p 'Mark: ' m && bb \"+mark:$m;$PWD\"", "Set "B("mark")}, - {{'\''}, "read -n1 -p 'Jump: ' j && bb \"+jump:$j\"", B("Jump")" to mark"}, + {{'\''}, "bb +cd:\"$(readlink -f ~/.config/bb/marks/\"$(ls ~/.config/bb/marks | " PICK("Jump to: ", "") ")\")\"", + B("Jump")" to a directory"}, + {{'-'}, "test $BBPREVPATH && bb +cd:\"$BBPREVPATH\"", "Go to "B("previous")" directory"}, + {{';'}, "bb +cd:''", "Go to "B("previous")" directory"}, + {{'0'}, "bb +cd:\"$BBINITIALPATH\"", "Go to "B("initial")" directory"}, + {{'m'}, "ln -s \"$PWD\" ~/.config/bb/marks/\"$("ASKECHO("Mark: ", "")")\"", B("Mark")" this directory"}, {{'r'}, "bb +refresh; " "for f; do " -- cgit v1.2.3