Compare commits

..

No commits in common. "addc8e2c9d5f09a5a8d2a126bf5060948b1f33f1" and "ff79dbcd648c3286701509532770a820fb5c9bfb" have entirely different histories.

4 changed files with 10 additions and 138 deletions

View file

@ -44,9 +44,6 @@ right: go to child dir
enter: go to child dir/open file enter: go to child dir/open file
backspace: go to parent dir backspace: go to parent dir
o: open file with
O: open file with a GUI program detached from file manager
g: go to top g: go to top
G: go to bottom G: go to bottom
@ -77,13 +74,14 @@ space: mark file
a: mark all files in directory a: mark all files in directory
d: trash d: trash
[1-9]: favourites/bookmarks (see customizing)
?: show help ?: show help
q: exit with last dir written to file q: exit with last dir written to file
ctrl+c exit without writing last dir ctrl+c exit without writing last dir
TO BE DONE: TO BE DONE:
o: open file with
O: open file with a GUI program detached from file manager
/: search /: search
c: copy c: copy
@ -93,6 +91,7 @@ b: bulk rename
p: execute paste/move/delete/bulk_rename p: execute paste/move/delete/bulk_rename
[1-9]: favourites/bookmarks (see customization)
``` ```
# Dependencies # Dependencies
@ -116,19 +115,6 @@ c() {
cd "$(cat "${XDG_CACHE_HOME:=${HOME}/.cache}/ccc/.ccc_d")" 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 ## Using `ccc` in neovim as a file picker
See [ccc.nvim](https://github.com/night0721/ccc.nvim) See [ccc.nvim](https://github.com/night0721/ccc.nvim)

39
ccc.1
View file

@ -24,9 +24,6 @@ right: go to child dir
enter: go to child dir/open file enter: go to child dir/open file
backspace: go to parent dir backspace: go to parent dir
o: open file with
O: open file with a GUI program detached from file manager
g: go to top g: go to top
G: go to bottom G: go to bottom
@ -57,11 +54,10 @@ space: mark file
a: mark all files in directory a: mark all files in directory
d: trash d: trash
[1-9]: favourites/bookmarks (see customizing)
?: show help ?: show help
q: exit with last dir written to file q: exit with last dir written to file
ctrl+c exit without writing last dir ctrl+c exit without writing last dir
. .
.fi .fi
. .
@ -70,38 +66,5 @@ ctrl+c exit without writing last dir
.nf .nf
Various settings can be changed in config.h file located in the program's directory. 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 .fi

85
ccc.c
View file

@ -71,8 +71,6 @@ void start_shell(void);
void yank_clipboard(void); void yank_clipboard(void);
void view_file_attr(void); void view_file_attr(void);
void show_history(void); void show_history(void);
void open_with(void);
void open_detached(void);
void wpprintw(const char *fmt, ...); void wpprintw(const char *fmt, ...);
void move_cursor(int row, int col); void move_cursor(int row, int col);
int readch(void); int readch(void);
@ -365,12 +363,7 @@ int main(int argc, char **argv)
break; break;
case 'o': case 'o':
open_with();
break;
case 'O': case 'O':
open_detached();
break;
case 'x': case 'x':
view_file_attr(); view_file_attr();
break; break;
@ -379,18 +372,6 @@ int main(int argc, char **argv)
show_history(); show_history();
break; 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 */ /* mark one file */
case SPACE: case SPACE:
add_file_stat(files->items[sel_file].name, files->items[sel_file].path, 1); add_file_stat(files->items[sel_file].name, files->items[sel_file].path, 1);
@ -459,8 +440,9 @@ void cleanup(void)
if (files->length != 0) { if (files->length != 0) {
arraylist_free(files); arraylist_free(files);
} }
free(marked->items); if (marked->length != 0) {
free(marked); arraylist_free(marked);
}
/* Restore old terminal settings */ /* Restore old terminal settings */
tcsetattr(STDIN_FILENO, TCSAFLUSH, &oldt); tcsetattr(STDIN_FILENO, TCSAFLUSH, &oldt);
bprintf("\033[2J\033[?1049l\033[?25h"); bprintf("\033[2J\033[?1049l\033[?25h");
@ -1320,67 +1302,6 @@ void show_history(void)
readch(); readch();
} }
void open_with(void)
{
char *input = get_panel_string("open with: ");
if (!input) {
return;
}
pid_t pid = fork();
if (pid == 0) {
/* Child process */
if (marked->length > 0) {
char *args[marked->length + 2];
args[0] = input;
for (int i = 0; i < marked->length; i++) {
args[i + 1] = marked->items[i].name;
}
args[marked->length + 1] = NULL;
execvp(input, args);
} else {
execlp(input, input, files->items[sel_file].name, NULL);
}
_exit(1); /* Exit if exec fails */
} else if (pid > 0) {
/* Parent process */
waitpid(pid, NULL, 0);
} else {
/* Fork failed */
wpprintw("fork failed: %s", strerror(errno));
}
}
void open_detached(void)
{
char *input = get_panel_string("open with (detached): ");
if (!input) {
return;
}
pid_t pid = fork();
if (pid == 0) {
/* Child process */
if (marked->length > 0) {
char *args[marked->length + 3];
args[0] = "nohup";
args[1] = input;
for (int i = 0; i < marked->length; i++) {
args[i + 2] = marked->items[i].name;
}
args[marked->length + 1] = NULL;
execvp("nohup", args);
} else {
execlp("nohup", "nohup", input, files->items[sel_file].name, NULL);
}
_exit(1); /* Exit if exec fails */
} else if (pid > 0) {
/* Parent process */
waitpid(pid, NULL, 0);
} else {
/* Fork failed */
wpprintw("fork failed: %s", strerror(errno));
}
}
/* /*
* Print line to the panel * Print line to the panel
*/ */

2
file.c
View file

@ -24,6 +24,7 @@ void arraylist_free(ArrayList *list)
if (list->items[i].stats != NULL) if (list->items[i].stats != NULL)
free(list->items[i].stats); free(list->items[i].stats);
} }
free(list->items); free(list->items);
free(list); free(list);
} }
@ -56,6 +57,7 @@ void arraylist_remove(ArrayList *list, long index)
free(list->items[index].name); free(list->items[index].name);
free(list->items[index].path); free(list->items[index].path);
free(list->items[index].stats); free(list->items[index].stats);
free(list->items[index].icon);
*/ */
for (long i = index; i < list->length - 1; i++) for (long i = index; i < list->length - 1; i++)
list->items[i] = list->items[i + 1]; list->items[i] = list->items[i + 1];