Add favourites feature and update manual

This commit is contained in:
Night Kaly 2024-11-17 23:51:19 +00:00
parent ff79dbcd64
commit 5da3b3b6be
Signed by: night0721
SSH key fingerprint: SHA256:B/hgVwUoBpx5vdNsXl9w8XwZljA9766uk6T4ubZp5HM
3 changed files with 60 additions and 1 deletions

View file

@ -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)

33
ccc.1
View file

@ -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

12
ccc.c
View file

@ -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);