diff --git a/README.md b/README.md index b0e5c7b..7c414b8 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,8 @@ space: mark file a: mark all files in directory d: trash +[1-9]: favourites/bookmarks (see customizing) + ?: show help q: exit with last dir written to file ctrl+c exit without writing last dir @@ -91,7 +93,6 @@ b: bulk rename p: execute paste/move/delete/bulk_rename -[1-9]: favourites/bookmarks (see customization) ``` # Dependencies @@ -115,6 +116,19 @@ c() { cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/ccc/.ccc_d")" } ``` +## Environment variables +```sh +export CCC_LAST_D=~/.cache/ccc/.ccc_d +export CCC_FAV1=~/projects +export CCC_FAV2=~/.bashrc +export CCC_FAV3=~/Pictures/Wallpapers/ +export CCC_FAV4=/usr/share +export CCC_FAV5=/ +export CCC_FAV6= +export CCC_FAV7= +export CCC_FAV8= +export CCC_FAV9= +``` ## Using `ccc` in neovim as a file picker See [ccc.nvim](https://github.com/night0721/ccc.nvim) diff --git a/ccc.1 b/ccc.1 index 9b2aac1..060e446 100644 --- a/ccc.1 +++ b/ccc.1 @@ -66,5 +66,38 @@ ctrl+c exit without writing last dir .nf Various settings can be changed in config.h file located in the program's directory. + +. +.fi +. +.SH "CD on Exit for POSIX Shell" +. +.nf + +# Add this to your .bashrc, .zshrc or equivalent. +# Run 'ccc' with 'c' or whatever you decide to name the function. +c() { + ccc "$@" + cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/ccc/.ccc_d")" +} + +. +.fi +. +.SH "Environment variables" +. +.nf + +export CCC_LAST_D=~/.cache/ccc/.ccc_d +export CCC_FAV1=~/projects +export CCC_FAV2=~/.bashrc +export CCC_FAV3=~/Pictures/Wallpapers/ +export CCC_FAV4=/usr/share +export CCC_FAV5=/ +export CCC_FAV6= +export CCC_FAV7= +export CCC_FAV8= +export CCC_FAV9= + . .fi diff --git a/ccc.c b/ccc.c index fd20f10..9330009 100644 --- a/ccc.c +++ b/ccc.c @@ -372,6 +372,18 @@ int main(int argc, char **argv) show_history(); break; + case '1': case '2': case '3': case '4': case '5': case '6': case '7': + case '8': case '9': + char envname[9]; + snprintf(envname, 9, "CCC_FAV%d", ch - '0'); + char *fav = getenv(envname); + if (fav && !strcmp(fav, "")) { + char dir[PATH_MAX]; + strcpy(dir, fav); + change_dir(dir, 0, 0); + } + break; + /* mark one file */ case SPACE: add_file_stat(files->items[sel_file].name, files->items[sel_file].path, 1);