Files
th/config.h
2025-07-18 23:01:49 +02:00

82 lines
3.9 KiB
C

#include "defines.h"
#include "interactions.h"
#include "sorting.h"
static const mimetype mimetype_default_cmd[] = {
/* mimetype shell command
* ^ substring of "file --mime-type -b ./hovered"
* this does mean that this list is checked for completely linear.
* Example:
* file --mime-type -b ./image.gif
* gives us "image/gif", thusly if we want to open gif in mpv rather than feh,
* we need to define "gif" before "image" */
{ "text", "$EDITOR" },
{ "gif", "mpv --loop-file=\"inf\"" },
{ "image", "feh" },
{ "video", "mpv" },
{ "audio", "mpv" }
};
static const extension file_extension_default_cmd[] = {
/* extension shell command
* similar to mimetype_default_cmd, however it searches for exact string matches
* and is checked before mimetype_default_cmd */
{ ".exe", "wine"},
};
static const binding key_binding[] = {
/*key action blackmagic comment*/
/*you cannot add bindings that include other bindings in its entirety
* possible: mk, mf
* not possible: gg, ggg
* trying to use ggg will always fail as it will execute gg first instead, resetting the input buffer, thus never reaching ggg */
/* blackmagic holds a modifier of an action, either as string or as function pointer depending on the action */
{ "q", quit_program, NULL, "quit" },
{ " ", toggle_selection, NULL, "toggle file selection" }, /* on hovered file/directory */
{ "e", update, NULL, "rerun all backend" }, /* executes the entire backend and redrawing of the screen */
{ "/", not_implemented, NULL, "search" },
{ "h", move_left, NULL, "move left" }, /* moves one dir up */
{ "t", move_down, NULL, "move down" },
{ "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 */
{ "r", rename_hovered, NULL, "rename hovered file" }, /* renames currently hovered file/directory */
{ "d", 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 */
{ "G", jump_bottom, NULL, "jump to last file in dir" },
{ "gg", jump_top, NULL, "jump to first file in dir" },
{ "gh", jump_to_dir, "$HOME", "jump to $HOME" },
{ "gs", jump_to_dir, "$START_PATH", "jump to $START_PATH" },
{ "gd", jump_to_dir, "/dev", "jump to /dev" },
{ "ge", jump_to_dir, "/etc", "jump to /etc" },
{ "gm", jump_to_dir, "/mnt", "jump to /mnt" },
{ "go", jump_to_dir, "/opt", "jump to /opt" },
{ "gt", jump_to_dir, "/tmp", "jump to /tmp" },
{ "gv", jump_to_dir, "/var", "jump to /var" },
{ "u7", cmd_on_selected, "7z x", "unzip 7z" },
{ "ub", cmd_on_selected, "tar -xvf", "unzip bz2" },
{ "ur", cmd_on_selected, "unrar x", "unzip rar" },
{ "ut", cmd_on_selected, "tar -xvf", "unzip tar" },
{ "ut", cmd_on_selected, "gzip -d", "unzip gzip" },
{ "uz", cmd_on_selected, "unzip ", "unzip zip" },
{ "on", order_by, sort_natural, "order natural" },
{ "or", not_implemented, "", "order reverse" },
{ "oe", not_implemented, "", "order extension" },
{ "os", order_by, sort_size, "order size" },
{ "ot", order_by, sort_type, "order type" },
{ "oz", order_by, sort_random, "order random" },
{ "oa", order_by, sort_alpha, "order alphabetically" },
{ "mk", makedir, NULL, "create directory" },
{ "mf", makefile, NULL, "create file" },
{ "a", toggle_hidden_files, NULL, "toggle hidden files" },
};
static const unsigned long binding_count = sizeof(key_binding) / sizeof(binding);
static const unsigned long mimetype_default_count = sizeof(mimetype_default_cmd) / sizeof(mimetype);
static const unsigned long file_extension_default_count = sizeof(file_extension_default_cmd) / sizeof(extension);