implementation of jump_to_dir
This commit is contained in:
@@ -378,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;
|
||||
|
||||
Reference in New Issue
Block a user