summaryrefslogtreecommitdiff
path: root/mac/.config/lf/lfrc
blob: c9b2d3662793f0c3f9e07bb4a55c5f56698a81a5 (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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
### --- Basic Settings --- ###
set autoquit true
set cleaner '~/.config/lf/cleaner'
set dircache false
set drawbox true
set dupfilefmt '%f_%n'
set hidden false
set hiddenfiles ".*:*.aux:*.log:*.bbl:*.bcf:*.blg:*.run.xml:*.smi:*.srt:*.ass"
set history false
set icons true
set ifs "\n"
set ignorecase true
set incsearch true
set incfilter true
set mouse true
set number true
set period 1
set previewer '~/.config/lf/scope'
set ratios 1:2:3
set relativenumber true
set scrolloff 10
set shellopts '-eu'
set tempmarks '123456'
set truncatepct 50


### --- Custom Functions --- ###
# Chmod
cmd chmods ${{
  options=$(printf "x\nu+x\na+x\n000\n644\n666\n755\n777")
  choice=$(printf "%s" "$options" | fzf)
  case "$choice" in
    "x") mod="+x";;
    "u+x") mod="u+x";;
    "a+x") mod="a+x";;
    "000") mod="000";;
    "644") mod="644";;
    "666") mod="666";;
    "755") mod="755";;
    "777") mod="777";;
  esac
  for file in $fx; do
    chmod -R $mod "$file"
  done
  printf "Permissions set to $mod for selected files/directories."
  lf -remote "send $id reload"
}}

# Compress
cmd compress ${{
  clear; tput cup $(($(tput lines)/3)); tput bold
  set -f
  printf "%s\n\t" "$fx"
  printf "compress?[y/N]"
  read ans
  [ $ans = "y" ] && {
    printf "%s\n\t" "$fx"
    printf "file name: "
    read ans
    mkdir $ans && {
      cp -r $fx $ans
      tar czf $ans.tar.gz $ans
      rm -rf $ans
    } || {
      printf "%s\n\t" "$fx"
      printf "Permissions needs.\n"
      printf "Continue in root?[y/N]"
      read root
      [ $root = "y" ] && {
        printf "Compressing $ans...\n"
        sudo mkdir $ans
        sudo cp -r $fx $ans
        sudo tar czf $ans.tar.gz $ans
        sudo rm -rf $ans
      }
    }
  }
}}

# Copy
cmd copyto ${{
  set -f
  clear; tput cup $(($(tput lines)/3))
	dest=$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" | fzf --layout=reverse --height 40% --prompt 'Copy to where? ' | sed 's|~|$HOME|')
	[ -z "$dest" ] && exit
	destpath=$(eval printf '%s' \"$dest\")
	clear; tput cup $(($(tput lines)/3)); tput bold
	echo "From:"
	echo "$fx" | sed 's/^/   /'
	printf "To:\n   %s\n\n\tcopy?[y/N]" "$destpath"
	read -r ans
	[ "$ans" != "y" ] && exit
  for x in $fx; do
    cp -ivr "$x" "$destpath"
  done &&
  notify-send "📋 File(s) copied." "File(s) copied to $destpath."
}}
cmd yank-dirname $dirname -- "$f" | head -c-1 | pbcopy clipboard
cmd yank-path $printf '%s' "$fx" | pbcopy clipboard
cmd yank-basename $basename -a -- $fx | head -c-1 | pbcopy clipboard
cmd yank-basename-without-extension &basename -a -- $fx | cut -d. -f1 | head -c-1 | pbcopy clipboard

# Create
cmd mkdir ${{ clear; tput cup $(($(tput lines)/3)); tput bold
  printf "Directory Name: "
  read ans
  mkdir -p $ans
}}
cmd mkfile ${{
  clear; tput cup $(($(tput lines)/3)); tput bold
  printf "File Name: "
  read ans
  $EDITOR $ans
}}
cmd link %{{
  set -- $(cat ~/.local/share/lf/files)
  mode="$1"
  shift
  if [ "$#" -lt 1 ]; then
    lf -remote "send $id echo no files to link"
    exit 0
  fi
  case "$mode" in
    # symbolically copy mode is indicating a soft link
    copy) ln -sr -t . -- "$@";;
    # while a move mode is indicating a hard link
    move) ln -t . -- "$@";;
  esac
  rm ~/.local/share/lf/files
  lf -remote "send clear"
}}

# Cut
cmd cut-add %{{
  sed '1s/.*/move/' "$XDG_DATA_HOME/lf/files" > "$XDG_DATA_HOME/lf/files.tmp"
  mv "$XDG_DATA_HOME/lf/files.tmp" "$XDG_DATA_HOME/lf/files"
  echo "$fx" >> "$XDG_DATA_HOME/lf/files"
  lf -remote "send $id unselect"
  lf -remote "send $id sync"
}}
cmd cut-remove %{{
  sed '1s/.*/move/' "$XDG_DATA_HOME/lf/files" > "$XDG_DATA_HOME/lf/files.tmp"
  mv "$XDG_DATA_HOME/lf/files.tmp" "$XDG_DATA_HOME/lf/files"
  echo "$fx" | while read -r file; do
    sed "\|$file|d" "$XDG_DATA_HOME/lf/files" > "$XDG_DATA_HOME/lf/files.tmp"
    mv "$XDG_DATA_HOME/lf/files.tmp" "$XDG_DATA_HOME/lf/files"
  done
  lf -remote "send $id unselect"
  lf -remote "send $id sync"
}}

# Delete
cmd delete ${{
  clear; tput cup $(($(tput lines)/3)); tput bold
  set -f
  printf "%s\n\t" "$fx"
  printf "delete?[y/N]"
  read ans
  [ $ans = "y" ] && {
    rm -rf -- $fx 2>/dev/null || {
      printf "sudo delete?[y/N]"
      read ans
      [ $ans = "y" ] && sudo rm -rf -- $fx
    }
  }
}}

cmd trash ${{
  files=$(printf "$fx" | tr '\n' ';')
  while [ "$files" ]; do
    file=${files%%;*}

    trash-put "$(basename "$file")"
    if [ "$files" = "$file" ]; then
      files=''
    else
      files="${files#*;}"
    fi
  done
}}

cmd restore_trash ${{
  trash-restore
}}

# Extract
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" ] && {
    case $fx in
      *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjf $fx;;
      *.tar.gz|*.tgz) tar xzf $fx                 ;;
      *.tar.xz|*.txz) tar xf $fx                  ;;
      *.bz2)        bunzip2 $fx                   ;;
      *.lzma)       unlzma $fx                    ;;
      *.rar)        unrar e $fx                   ;;
      *.gz)         gunzip $fx                    ;;
      *.tar)        tar xf $fx                    ;;
      *.xz)         unxz $fx                      ;;
      *.zip|*.jar|*.war|*.7z) 7z x $fx            ;;
      *.Z)          uncompress $fx                ;;
      *.exe)        cabextract $fx                ;;
      *.ace)        unace x $fx                   ;;
    esac
  }
}}

# Git
cmd on-cd &{{
  zoxide add "$PWD"
  bash -c '
  # display git repository status in your prompt
  source /usr/share/git/completion/git-prompt.sh
  GIT_PS1_SHOWDIRTYSTATE=auto
  GIT_PS1_SHOWSTASHSTATE=auto
  GIT_PS1_SHOWUNTRACKEDFILES=auto
  GIT_PS1_SHOWUPSTREAM=auto
  git=$(__git_ps1 " (%s)")

  fmt="\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f$git\033[0m"
  lf -remote "send $id set promptfmt \"$fmt\""
  '
}}

# iPython
cmd create-ipynb ${{
  clear; tput cup $(($(tput lines)/3)); tput bold
  printf "File Name: "
  read ans
  vipy $ans
}}

# Move
cmd moveto ${{
  set -f
  clear; tput cup $(($(tput lines)/3))
	dest=$(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' "${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs" | fzf --layout=reverse --height 40% --prompt 'Move to where? ' | sed 's|~|$HOME|')
	[ -z "$dest" ] && exit
	destpath=$(eval printf '%s' \"$dest\")
	clear; tput cup $(($(tput lines)/3)); tput bold
	echo "From:"
	echo "$fx" | sed 's/^/   /'
	printf "To:\n   %s\n\n\tmove?[y/N]" "$destpath"
	read -r ans
	[ "$ans" != "y" ] && exit
  for x in $fx; do
    mv -iv "$x" "$destpath"
  done &&
  notify-send "🚚 File(s) moved." "File(s) moved to $destpath."
}}

# MPV
cmd mpvdir ${{
  if [ -n "$fx" ]; then
    set -- $fx
    setsid -f mpv --x11-name=video --really-quiet -- "$@"
  else
    for file in $(printf '%s\n' *.mp4 *.mkv *.avi *.flv *.webm *.mov *.mpg *.3gp *.ts *.rmvb | sort); do
      [ -e "$file" ] && set -- "$@" "$file"
    done
    [ -n "$1" ] && setsid -f mpv --x11-name=video --really-quiet -- "$@"
  fi

  lf -remote "send $id :clear; unselect; save-select"
}}

# Open
# cmd open ${{
#   case $(file --mime-type "$(readlink -f $f)" -b) in
#   application/octet-stream)
#     case ${f##*.} in
#     doc|docx|xls|xlsx|odt|ppt|pptx) libreoffice $fx >/dev/null 2>&1 ;;
#     ghw) gtkwave $f >/dev/null 2>&1 ;;
#     ts) mpv --x11-name=video $f -quiet >/dev/null 2>&1 ;;
#     *) zathura $fx >/dev/null 2>&1 ;;
#     esac
#     ;;
#   application/epub*|application/pdf|application/postscript|application/vnd.djvu|image/vnd.djvu) zathura $fx >/dev/null 2>&1 ;;
#   application/pgp-encrypted) $EDITOR $fx ;;
#   application/vnd.oasis.opendocument.text|application/vnd.oasis.opendocument.spreadsheet|application/vnd.oasis.opendocument.spreadsheet-template|application/vnd.oasis.opendocument.presentation-template|application/vnd.oasis.opendocument.presentation|application/vnd.ms-powerpoint|application/vnd.oasis.opendocument.graphics|application/vnd.oasis.opendocument.graphics-template|application/vnd.oasis.opendocument.formula|application/vnd.oasis.opendocument.database) firefox $fx >/dev/null 2>&1 ;;
#   application/x-hwp|application/vnd.openxmlformats-officedocument.presentationml.presentation|application/vnd.openxmlformats-officedocument.wordprocessingml.document) libreoffice $fx >/dev/null 2>&1 ;;
#   audio/*|video/x-ms-asf) mpv --volume=50 --x11-name=music --force-window=yes --audio-display=embedded-first $f >/dev/null 2>&1 ;;
#   image/x-xcf) gimp $f >/dev/null 2>&1 ;;
#   image/svg+xml) display -- $f ;;
#   image/*) rotdir $f | grep -i "\.\(png\|jpg\|jpeg\|gif\|webp\|avif\|tif\|ico\)\(_large\)*$" |
#     nsxiv -aiop 2>/dev/null | while read -r file; do
#       [ -z "$file" ] && continue
#       lf -remote "send select \"$file\""
#       lf -remote "send toggle"
#     done &
#     ;;
#   text/csv|application/vnd.openxmlformats-officedocument.spreadsheetml.sheet) sc-im $fx;;
#   text/html|text/xml) lynx $fx;;
#   text/troff) groff -mom $fx -Tpdf | zathura - ;;
#   text/*|application/json|inode/x-empty|application/x-subrip) $EDITOR $fx;;
#   video/*) mpv --x11-name=video -quiet $f >/dev/null 2>&1 ;;
# 	*) for f in $fx; do open -a $f >/dev/null 2>&1; done;;
#   esac
# }}

# Rename
cmd bulkrename ${{
  tmpfile_old="$(mktemp)"
  tmpfile_new="$(mktemp)"

  [ -n "$fs" ] && fs=$(basename -a $fs) || fs=$(ls)

  echo "$fs" > "$tmpfile_old"
  echo "$fs" > "$tmpfile_new"
  $EDITOR "$tmpfile_new"

  [ "$(wc -l < "$tmpfile_old")" -eq "$(wc -l < "$tmpfile_new")" ] || { rm -f "$tmpfile_old" "$tmpfile_new"; exit 1; }

  paste "$tmpfile_old" "$tmpfile_new" | while IFS="$(printf '\t')" read -r src dst
  do
    [ "$src" = "$dst" ] || [ -e "$dst" ] || mv -- "$src" "$dst"
  done

  rm -f "$tmpfile_old" "$tmpfile_new"
  lf -remote "send $id unselect"
}}

# Samba
cmd share-samba ${{
  printf "%s\n\t" "$fx"
  printf "Share this folder?[y/N]"
  read ans
  [ $ans = "y" ] && dmenusamba "$f"
}}

# Select
cmd select-type &{{
  set -f
  [ "$#" -eq 0 ] && exit
  files="$(
    find "$PWD" -mindepth 1 -maxdepth 1 \
    \( \( -type "$1" -o \( -type l -a -exec test -"$1" {} \; \) \) \) \
    $([ "$lf_hidden" = false ] && printf '%s\n' -not -name '.*') -print0 |
    sort -z |
    sed -z 's/\\/\\\\/g;s/"/\\"/g;s/\n/\\n/g;s/^/"/;s/$/"/' |
    tr '\0' ' ')"
  [ -n "$files" ] && lf -remote "send $id :unselect; toggle $files"
}}
cmd select-dirs select-type d
cmd select-files select-type f
cmd select-videos &{{
  set -f
  files="$(
    find "$PWD" -mindepth 1 -maxdepth 1 \( \( -type f -o \( -type l -a -exec test -f {} \; \) \) \) \( -iname '*.mp4' -o -iname '*.mkv' -o -iname '*.flv' -o -iname '*.avi' -o -iname '*.webm' -o -iname '*.mov' -o -iname '*.mpg' -o -iname '*.ts' -o -iname '*.wmv' -o -iname '*.vob' -o -iname '*.3gp' -o -iname '*.rmvb' \) \
    $([ "$lf_hidden" = false ] && printf '%s\n' ! -name '.*') -print0 |
    sort -z |
    sed -z 's/\\/\\\\/g;s/"/\\"/g;s/\n/\\n/g;s/^/"/;s/$/"/' |
    tr '\0' ' ')"
  [ -n "$files" ] && lf -remote "send $id :unselect; toggle $files"
}}
cmd select-images &{{
  set -f
  files="$(
    find "$PWD" -mindepth 1 -maxdepth 1 \( \( -type f -o \( -type l -a -exec test -f {} \; \) \) \) \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.gif' -o -iname '*.bmp' -o -iname '*.tiff' -o -iname '*.tif' -o -iname '*.svg' -o -iname '*.webp' \) \
    $([ "$lf_hidden" = false ] && printf '%s\n' ! -name '.*') -print0 |
    sort -z |
    sed -z 's/\\/\\\\/g;s/"/\\"/g;s/\n/\\n/g;s/^/"/;s/$/"/' |
    tr '\0' ' ')"
  [ -n "$files" ] && lf -remote "send $id :unselect; toggle $files"
}}
cmd select-music &{{
  set -f
  files="$(
    find "$PWD" -mindepth 1 -maxdepth 1 \( \( -type f -o \( -type l -a -exec test -f {} \; \) \) \) \( -iname '*.mp3' -o -iname '*.flac' -o -iname '*.wav' -o -iname '*.aac' -o -iname '*.ogg' -o -iname '*.m4a' -o -iname '*.wma' \) \
    $([ "$lf_hidden" = false ] && printf '%s\n' ! -name '.*') -print0 |
    sort -z |
    sed -z 's/\\/\\\\/g;s/"/\\"/g;s/\n/\\n/g;s/^/"/;s/$/"/' |
    tr '\0' ' ')"
  [ -n "$files" ] && lf -remote "send $id :unselect; toggle $files"
}}
cmd on-select &{{
  lf -remote "send $id set statfmt \"$(eza -ld --color=always "$f")\""
}}
cmd load-select &{{
    if [ $# -eq 1 ] && [ "$1" = "$id" ]; then
        exit
    fi
    lf -remote "send $id unselect"
    if [ -s ~/.local/share/lf/select ]; then
        files="$(sed 's/\\/\\\\/g;s/"/\\"/g;s/^/"/;s/$/"/' ~/.local/share/lf/select | tr '\n' ' ')"
        lf -remote "send $id toggle $files"
    fi
}}
cmd save-select &{{
  printf "%s" "$fs" > ~/.local/share/lf/select
  lf -remote "send load-select $id"
}}
cmd alt-paste &{{
  [ -n "$fs" ] && lf -remote "send $id :$1; save-select"
  lf -remote "send $id paste" || {
    clear; tput cup $(($(tput lines)/3)); tput bold
    set -f
    printf "%s\n\t" "$fx"
    printf "Permissions needs.\n"
    printf "Continue in root?[y/N]"
    read root
    [ $root = "y" ] && sudo lf -remote "send $id paste"
  }

  lf -remote "send $id :clear"
}}

# Traversal
cmd fzf $nvim $(find . -name "$1" | fzf)
cmd fzf_search ${{
  RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
  res="$(
    FZF_DEFAULT_COMMAND="$RG_PREFIX ''" \
      fzf --bind "change:reload:$RG_PREFIX {q} || true" \
      --ansi --layout=reverse --header 'Search in files' \
      | cut -d':' -f1 | sed 's/\\/\\\\/g;s/"/\\"/g'
  )"
  [ -n "$res" ] && lf -remote "send $id select \"$res\""
}}
cmd z %{{
	result="$(zoxide query --exclude $PWD $@ | sed 's/\\/\\\\/g;s/"/\\"/g')"
	lf -remote "send $id cd \"$result\""
}}
cmd zi ${{
	result="$(zoxide query -i | sed 's/\\/\\\\/g;s/"/\\"/g')"
	lf -remote "send $id cd \"$result\""
}}
cmd follow_link %{{
  lf -remote "send ${id} select '$(readlink $f)'"
}}
cmd lastfiles ${{
  list=$(nvim -u NONE --headless +'lua io.write(table.concat(vim.v.oldfiles, "\n") .. "\n")' +qa)
  file=$(printf "%s" "$list" | while read -r file; do
    [ -f "$file" ] && printf "%s\n" "$file"
  done | fzf --reverse || lf -remote "send $id reload")
  [ -n "$file" ] && $EDITOR "$file"
}}
cmd edit-config ${{
  $EDITOR ~/.config/lf/lfrc
  lf -remote "send $id source ~/.config/lf/lfrc"
}}

cmd wine-run ${{
  if [ $(file --mime-type "$(readlink -f $f)" -b) = "application/vnd.microsoft.portable-executable" ]; then
    file="${f##*/}"
    file="${file%.*}"
    export WINEPREFIX="${WINEPREFIX:-${XDG_DATA_HOME:-${HOME}/.local/share}/wine}/$file"
    wine $f
  fi
}}

# Wallpaper
cmd setbg "$1"
cmd setlock "$1"

### --- Bindings --- ###
# Unbinding
map b
map c
map d
map f
map g
map H
map M
map p
map s
map t
map v
map w
map y
map z

# Shortcuts
source ~/.config/lf/shortcutrc

# Chmod
map zx chmods

# Clear && Unselect
map <c-l> :clear; unselect; save-select
map <c-x> :clear; unselect; save-select

# Compress
map C compress

# Copy
# map yy %cp -ri -- $fs .; clear
map Y $printf "%s" "$fx" | pbcopy clipboard; clear; save-select
map yb yank-basename
map yd yank-dirname
map ye copyto; clear; save-select
map yl $printf "%s" "$fx" | sed -E 's/^.+\[/https:\/\/piped.video\/watch?v=/' | sed -E 's/\]\..+//' | pbcopy clipboard
map yn yank-basename-without-extension
map yp yank-path
map yt $printf "%s" "$fx" | sed -E 's/^.+\[/https:\/\/www.youtube.com\/watch?v=/' | sed -E 's/\]\..+//' | pbcopy clipboard
map yy copy

# Create
map Md mkdir
map Mf mkfile
map Ml link

# Cut
map dd cut-add
map dr cut-remove

# Delete
map D trash; clear; save-select
map <delete> delete; clear; save-select

# Editor
map <enter> $$EDITOR "$f"
map <c-v> push :!nvim<space>
map vlf edit-config
map vll lastfiles
map vln $$EDITOR "$(nvim -u NONE --headless +'lua io.write(vim.v.oldfiles[1] .. "\n")' +qa)"

# Extract
map E extract; clear; save-select

# iPython
map Mi create-ipynb

# Move
map Mt moveto; clear; save-select

# MPV
map Mpv mpvdir

# Nsxiv
map th $nsxiv -apt "$(pwd)"

# Open
map O $mimeopen "$f"
map o open "$f"
map <c-o> $mimeopen --ask "$f"

# Paste
map PP alt-paste cut
map pp alt-paste copy

# Preview
map zd set dirpreviews!
map zp set preview!

# Program
map T $setsid -f $TERMINAL >/dev/null 2>&1
map x $$f
map X !$f

# Quit
map <esc> quit
map <c-c> quit

# Rename
map a :rename; cmd-right # after extension
map A :rename; cmd-end # at the very end
map B bulkrename
map r :rename; cmd-delete-home # filename
map R :rename; cmd-end; cmd-delete-home # entire filename
map i :rename # before extension
map I :rename; cmd-home # at the very beginning

# Redraw && Reload
map <c-r> :redraw; reload

# Restore
map U restore_trash

# Samba
map SMB share-samba

# Select
map <space> :toggle; down; save-select
map sb :invert-below; save-select
map sd select-dirs
map sf select-files
map si :invert; save-select
map sm select-music
map sp select-images
map su :unselect; save-select
map sU :glob-unselect; save-select
map sv select-videos

# Sort
map sa :set sortby atime; set info atime
map sc :set sortby ctime; set info ctime
map se :set sortby ext; set info
map sn :set sortby natural; set info
map st :set sortby time; set info time
map sz :set sortby size; set info size

# Tag
map tg tag-toggle

# Traversal
map fa $lf -remote "send $id select \"$(fzf)\""
map fb $lf -remote "send $id cd $(sed -e 's/\s*#.*//' -e '/^$/d' -e 's/^\S*\s*//' ${XDG_CONFIG_HOME:-$HOME/.config}/shell/bm-dirs | fzf)"
map fD zi
map fd $lf -remote "send $id select \"$(find . -type d | fzf)\""
map ff $lf -remote "send $id select \"$(find . -type f | fzf)\""
map gl follow_link
map <c-f> fzf_search
map <c-z> z

# Wallpaper
map bg $setbg "$f"
map bl $setlock "$f"

# Wine
map wi wine-run

load-select