fe

terminal file explorer and picker

git clone https://9o.is/git/fe.git

config.h

(3430B)


      1 #include "tty.h"
      2 #include "tty_interface.h"
      3 #include "options.h"
      4 
      5 #define TTY_COLOR_BLACK 0
      6 #define TTY_COLOR_RED 1
      7 #define TTY_COLOR_GREEN 2
      8 #define TTY_COLOR_YELLOW 3
      9 #define TTY_COLOR_BLUE 4
     10 #define TTY_COLOR_MAGENTA 5
     11 #define TTY_COLOR_CYAN 6
     12 #define TTY_COLOR_WHITE 7
     13 #define TTY_COLOR_NORMAL 9
     14 
     15 #define COLOR_DIRECTORY TTY_COLOR_BLUE
     16 #define COLOR_LINK      TTY_COLOR_CYAN
     17 #define COLOR_SOCK      TTY_COLOR_YELLOW
     18 #define COLOR_FIFO      TTY_COLOR_MAGENTA
     19 #define COLOR_EXEC      TTY_COLOR_GREEN
     20 #define COLOR_REGULAR   TTY_COLOR_NORMAL
     21 
     22 #define KEY(key) ((const char[]){key, '\0'})
     23 #define KEY_CTRL(key) ((const char[]){((key) - ('@')), '\0'})
     24 
     25 static const keybinding_t keybindings[] = {
     26     {"\x1b",        action_exit,            NULL}, /* ESC */
     27     {KEY_CTRL('C'), action_exit,            NULL}, /* C-C */
     28     {KEY_CTRL('M'), action_select,          NULL}, /* CR */
     29     {KEY_CTRL('P'), action_prev,            NULL}, /* C-P */
     30     {KEY_CTRL('N'), action_next,            NULL}, /* C-N */
     31     {KEY_CTRL('K'), action_prev,            NULL}, /* C-K */
     32     {KEY_CTRL('J'), action_next,            NULL}, /* C-J */
     33     {KEY_CTRL('U'), action_halfpageup,      NULL}, /* C-U */
     34     {KEY_CTRL('D'), action_halfpagedown,    NULL}, /* C-D */
     35     {KEY('q'),      action_exit,            NULL}, /* q */
     36     {KEY('r'),      action_reload,          NULL}, /* r */
     37     {KEY('g'),      action_first,           NULL}, /* g */
     38     {KEY('G'),      action_last,            NULL}, /* G */
     39     {KEY('~'),      action_home,            NULL}, /* ~ */
     40     {KEY('.'),      action_togglehidden,    NULL}, /* . */
     41     {KEY('%'),      action_create,          NULL}, /* % (create) */
     42     {KEY('D'),      action_mkdir,           NULL}, /* D (mkdir) */
     43     {KEY('d'),      action_remove,          NULL}, /* d (delete/remove) */
     44     {KEY('x'),      action_cut,             NULL}, /* x (cut) */
     45     {KEY('y'),      action_copy,            NULL}, /* y */
     46     {KEY('p'),      action_paste,           NULL}, /* p */
     47     {KEY('l'),      action_run,             "less %s/%s"},                     /* l (less/look) */
     48     {KEY('t'),      action_run,             "tmux new-window -b 'vis %s/%s'"}, /* edit new tab */
     49     {KEY('f'),      action_setpath,         "ag -g . %s | fzy"},               /* f (find) */
     50     {KEY('s'),      action_setpath,         "fish -c fzyg"},                   /* s (search/grep) */
     51     {KEY('-'),      action_parent,          NULL}, /* - */
     52     {"\x1bOD",      action_parent,          NULL}, /* LEFT */
     53     {"\x1b[D",      action_parent,          NULL}, /* LEFT */
     54     {"\x1bOC",      action_select,          NULL}, /* RIGHT */
     55     {"\x1b[C",      action_select,          NULL}, /* RIGHT */
     56     {"\x1b[A",      action_prev,            NULL}, /* UP */
     57     {"\x1bOA",      action_prev,            NULL}, /* UP */
     58     {"\x1b[B",      action_next,            NULL}, /* DOWN */
     59     {"\x1bOB",      action_next,            NULL}, /* DOWN */
     60     {"\x1b[5~",     action_pageup,          NULL},
     61     {"\x1b[6~",     action_pagedown,        NULL},
     62     {"\x1b[200~",   action_ignore,          NULL},
     63     {"\x1b[201~",   action_ignore,          NULL},
     64     {NULL, NULL, NULL}};
     65 
     66 static const options_t default_options = {
     67     .num_files = 25,
     68     .tty_filename = "/dev/tty",
     69     .keytimeout = 25,
     70     .sort_dir = 1,
     71     .sort_icase = 1,
     72     .sort_mtime = 0,
     73     .show_hidden = 1,
     74     .keybindings = keybindings,
     75 };
     76 
     77 #undef KEY_CTRL
     78 #undef KEY