Compare commits
3 Commits
87bfdd1b86
...
5a31f452ea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a31f452ea | ||
|
|
daf43daa00 | ||
|
|
cf03a230b6 |
2
config.h
2
config.h
@@ -68,7 +68,7 @@ static const binding key_binding[] = {
|
||||
{ "n", move_up, NULL, "move up" },
|
||||
{ "s", move_right, NULL, "move right" }, /* if a dir is hovered, cd into it, if a file is selected, see mimetype_default_cmd */
|
||||
|
||||
{ "\n", open_with, NULL, "open \"open with\" dialog" }, /* opens the hovered file with an arbitrary command */
|
||||
{ "\n", open_with, NULL, "open \"open with\" dialog" }, /* execute shell cmd on file, accounts for SETTINGS_COMMAND_FORK */
|
||||
{ "r", rename_hovered, NULL, "rename hovered file" }, /* renames currently hovered file/directory */
|
||||
{ "dD", delete, NULL, "delete file" }, /* deletes currently hovered OR selected file/directory
|
||||
* this means that it does not delete the hovered files if files are already selected */
|
||||
|
||||
@@ -281,7 +281,31 @@ void jump_top(){
|
||||
status |= (STATUS_RUN_BACKEND);
|
||||
}
|
||||
void open_with(){
|
||||
TODO;
|
||||
wclear(win_b);
|
||||
char *cmd;
|
||||
char *str = malloc(INPUT_BUFFER_SIZE);
|
||||
char *parsed_ui_text = parse_cmd(ui_open_with_text, mid_dir.current_file);
|
||||
mvwprintw(win_b, 0, 0, parsed_ui_text);
|
||||
if (read_string(win_b, 0, strlen(parsed_ui_text)+1, str) == 0) {
|
||||
if (str[0] == SETTINGS_COMMAND_FORK) {
|
||||
cmd = parse_cmd(str+1, mid_dir.current_file);
|
||||
pid_t pid = fork();
|
||||
if (pid == 0 && setsid()) {
|
||||
system(cmd);
|
||||
status = STATUS_QUIT_PROGRAM;
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
cmd = parse_cmd(str, mid_dir.current_file);
|
||||
if (system(cmd)) {
|
||||
}
|
||||
}
|
||||
free(cmd);
|
||||
}
|
||||
free(parsed_ui_text);
|
||||
free(str);
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_CLEAR);
|
||||
|
||||
}
|
||||
void rename_hovered(){
|
||||
wclear(win_b);
|
||||
@@ -354,7 +378,33 @@ void not_implemented(unsigned long passes, int index){
|
||||
TODO;
|
||||
}
|
||||
void jump_to_dir(unsigned long passes, int index){
|
||||
TODO;
|
||||
(void)passes;
|
||||
|
||||
unsigned long len;
|
||||
char *c = strchr(key_binding[index].black_magic, '/');
|
||||
if (c) {
|
||||
len = c - (char*)key_binding[index].black_magic;
|
||||
} else {
|
||||
len = strlen(key_binding[index].black_magic);
|
||||
}
|
||||
|
||||
char *to_env = malloc(len + 1);
|
||||
memcpy(to_env, key_binding[index].black_magic, len);
|
||||
to_env[len] = '\0';
|
||||
char *env = getenv(to_env + 1); /*+1 to remove the '$' prefix, freeing env always segfaults*/
|
||||
|
||||
if (env) {
|
||||
char *path = malloc(strlen(key_binding[index].black_magic) + strlen(env) + 1);
|
||||
memcpy(path, env, strlen(env));
|
||||
memcpy(path + strlen(env), key_binding[index].black_magic + len, strlen(key_binding[index].black_magic)+1);
|
||||
change_dir(path);
|
||||
free(path);
|
||||
} else {
|
||||
change_dir(key_binding[index].black_magic);
|
||||
}
|
||||
free(to_env);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_UPDATE_SCREEN_MASK | STATUS_RELOAD_DIRECTORY );
|
||||
}
|
||||
void order_by(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
@@ -365,7 +415,13 @@ void order_by(unsigned long passes, int index){
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
}
|
||||
void cmd_on_selected(unsigned long passes, int index){
|
||||
TODO;
|
||||
(void)passes;
|
||||
|
||||
char *cmd = parse_cmd(key_binding[index].black_magic, mid_dir.current_file);
|
||||
system(cmd);
|
||||
free(cmd);
|
||||
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY | STATUS_UPDATE_SCREEN_CLEAR);
|
||||
}
|
||||
void yank_file_name(){
|
||||
char *cmd = parse_cmd(clipboard_cmd, mid_dir.current_file);
|
||||
|
||||
Reference in New Issue
Block a user