summaryrefslogtreecommitdiff
path: root/modules/lf.nix
blob: 2dc71d16e5303d49ca05ac1d10143e6772ad3b31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{ config, pkgs, ... }:

{
  programs.lf = {
    enable = true;
    settings = {
      shell = "sh";
      icons = true;
      drawbox = true;
      scrolloff = 10;
      shellopts = "-eu";
    };
    commands = {
      extract = ''
        %{{
          set -f
          case $f in
              *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
              *.tar.gz|*.tgz) tar xzvf $f;;
              *.tar.xz|*.txz) tar xJvf $f;;
              *.zip) unzip $f;;
              *.rar) unrar x $f;;
              *.7z) 7z x $f;;
          esac
        }}
      '';
      open = ''
        %{{
          case $(file --mime-type -Lb $f) in
              text/*|application/json) lf -remote "send $id \$$EDITOR \$fx";;
              *) for f in $fx; do $OPENER $f > /dev/null 2> /dev/null & done;;
          esac
        }}
      '';
    };
    keybindings = {
      "<enter>" = "shell";
      "." = "set hidden!";
    };
  };
}