summaryrefslogtreecommitdiff
path: root/lf/lfrc
blob: 40375bd2740938b8981bf0ea178f8f1389e6b9d8 (plain) (blame)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# map . set hidden!

set shell sh 
set info size
set dircounts
set hidden
set number
set relativenumber
set ratios 1:1:2:3:5

# ranger legacy commands
map J push 7j
map K push 7k
map } half-down
map { half-up
map a rename

# execute current file (must be executable)
map x $$f
map X !$f

cmd open $nvim $fx # use nvim for files

# git support
map gp ${{clear; git pull --rebase || true; echo "press ENTER"; read ENTER}}
map gs ${{clear; git status; echo "press ENTER"; read ENTER}}
map gl ${{clear; git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit}}

# fzf support
cmd fzf ${{
    res="$(find . | fzf --reverse | sed 's/\\/\\\\/g;s/"/\\"/g')"
    if [ -d "$res" ] ; then
        cmd="cd"
    elif [ -f "$res" ] ; then
        cmd="select"
    else
        exit 0
    fi
    lf -remote "send $id $cmd \"$res\""
}}
map F fzf

# rg/ripgrep support
cmd rg ${{
    res="$( \
        RG_PREFIX="rg --column --line-number --no-heading --color=always \
            --smart-case "
        FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \
            fzf --reverse --bind "change:reload:$RG_PREFIX {q} || true" \
            --ansi --layout=reverse --header 'Search in files' \
            | cut -d':' -f1
    )"
    [ ! -z "$res" ] && lf -remote "send $id select \"$res\""
}}
map R rg


set preview
set previewer ~/.config/lf/preview.sh
map i $~/.config/lf/preview.sh $f | less -RX