Repository navigation
Expand file tree
/
Copy pathlfrc
More file actions
177 lines (154 loc) · 4.28 KB
/
Copy pathlfrc
File metadata and controls
177 lines (154 loc) · 4.28 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#######################################################################
# Basic Settings #
#######################################################################
set shell sh
set shellopts '-eu'
set ifs "\n"
set scrolloff 10
set preview true
set hidden true
set drawbox true
set icons true
set ignorecase true
set mouse
set timefmt '2006-01-02 15:04:05'
set cursorpreviewfmt "\033[7;2m"
# # ctpv preview
# set previewer ctpv
# set cleaner ctpvclear
# &ctpv -s $id
# &ctpvquit $id
# Pistol preview
set previewer ~/go/bin/pistol
#######################################################################
# cmds/functions #
#######################################################################
# define a custom 'open' command
# This command is called when current file is not a directory. You may want to
# use either file extensions and/or mime types here. Below uses an editor for
# text files and a file opener for the rest.
cmd open ${{
test -L $f && f=$(readlink -f $f)
case $(file --mime-type $f -b) in
text/*) $EDITOR $fx;;
*) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
esac
}}
cmd mkdir $mkdir -p "$(echo $* | tr ' ' '\ ')"
cmd mkfile $touch "$(echo $* | tr ' ' '\ ')"
cmd chmod ${{
printf "Mode Bits: "
read ans
for file in "$fx"
do
chmod $ans $file
done
lf -remote 'send reload'
}}
cmd extract ${{
clear; tput cup $(($(tput lines)/3)); tput bold
set -f
printf "%s\n\t" "$fx"
printf "extract?[y/N]"
read ans
[ $ans = "y" ] && atool -x $fx
}}
cmd delete ${{
clear; tput cup $(($(tput lines)/3)); tput bold
set -f
printf "$fx\n"
printf "delete?[y/n]"
read ans
[ "$ans" = "y" ] && rm -rf $fx
# [ "$ans" = "y" ] && trash $fx
}}
cmd moveto ${{
clear; tput cup $(($(tput lines)/3)); tput bold
set -f
clear; echo "Move to where?"
dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
for x in $fx; do
eval mv -iv \"$x\" \"$dest\"
done &&
notify-send "🚚 File(s) moved." "File(s) moved to $dest."
}}
cmd copyto ${{
clear; tput cup $(($(tput lines)/3)); tput bold
set -f
clear; echo "Copy to where?"
dest="$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf | sed 's|~|$HOME|')" &&
for x in $fx; do
eval cp -ivr \"$x\" \"$dest\"
done &&
notify-send "📋 File(s) copied." "File(s) copies to $dest."
}}
cmd fzf_jump ${{
res="$(find . -maxdepth 3 | fzf --reverse --header='Jump to location')"
if [ -f "$res" ]; then
cmd="select"
elif [ -d "$res" ]; then
cmd="cd"
fi
lf -remote "send $id $cmd \"$res\""
}}
cmd on-cd &{{
# display git repository status in your prompt
source ~/.config/lf/git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=auto
GIT_PS1_SHOWSTASHSTATE=auto
GIT_PS1_SHOWUNTRACKEDFILES=auto
GIT_PS1_SHOWUPSTREAM=auto
GIT_PS1_COMPRESSSPARSESTATE=auto
git=$(__git_ps1 " [GIT BRANCH:> %s]") || true
fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[33;1m$git\033[0m"
lf -remote "send $id set promptfmt \"$fmt\""
}}
cmd z %{{
result="$(zoxide query --exclude "${PWD}" -- "$@")"
lf -remote "send ${id} cd '${result}'"
}}
cmd zi ${{
result="$(zoxide query -i -- "$@")"
lf -remote "send ${id} cd '${result}'"
}}
# compress current file or selected files with tar and gunzip
cmd tar ${{
set -f
mkdir $1
cp -r $fx $1
tar czf $1.tar.gz $1
rm -rf $1
}}
# compress current file or selected files with zip
cmd zip ${{
set -f
mkdir $1
cp -r $fx $1
zip -r $1.zip $1
rm -rf $1
}}
#######################################################################
# Bindings #
#######################################################################
# use enter for shell commands
map <enter> shell
# execute current file (must be executable)
map x $$f
map X !$f
# dedicated keys for file opener actions
map o &mimeopen $f
map O $mimeopen --ask $f
map <c-f> fzf_jump
map dd delete
map <delete> delete
map p paste
map x cut
map y copy
map r rename
map <c-e> extract
map yy copyto
map M moveto
map <c-r> reload
map <c-s> set hidden!
map <c-u> unselect
map V push :!nvim<space>