Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.8 KiB

  1. # interpreter for shell commands
  2. set shell sh
  3. # set '-eu' options for shell commands
  4. # These options are used to have safer shell commands. Option '-e' is used to
  5. # exit on error and option '-u' is used to give error for unset variables.
  6. # Option '-f' disables pathname expansion which can be useful when $f, $fs, and
  7. # $fx variables contain names with '*' or '?' characters. However, this option
  8. # is used selectively within individual commands as it can be limiting at
  9. # times.
  10. set shellopts '-eu'
  11. # set internal field separator (IFS) to "\n" for shell commands
  12. # This is useful to automatically split file names in $fs and $fx properly
  13. # since default file separator used in these variables (i.e. 'filesep' option)
  14. # is newline. You need to consider the values of these options and create your
  15. # commands accordingly.
  16. set ifs "\n"
  17. # leave some space at the top and the bottom of the screen
  18. set scrolloff 10
  19. # use enter for shell commands
  20. map <enter> shell
  21. # execute current file (must be executable)
  22. map x $$f
  23. map X !$f
  24. # dedicated keys for file opener actions
  25. map o &mimeopen $f
  26. map O $mimeopen --ask $f
  27. # define a custom 'open' command
  28. # This command is called when current file is not a directory. You may want to
  29. # use either file extensions and/or mime types here. Below uses an editor for
  30. # text files and a file opener for the rest.
  31. cmd open ${{
  32. case $(file --mime-type $f -b) in
  33. text/*) $EDITOR $fx;;
  34. *) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
  35. esac
  36. }}
  37. # define a custom 'rename' command without prompt for overwrite
  38. # cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
  39. # map r push :rename<space>
  40. # make sure trash folder exists
  41. # %mkdir -p ~/.trash
  42. # move current file or selected files to trash folder
  43. # (also see 'man mv' for backup/overwrite options)
  44. cmd trash %set -f; mv $fx ~/.trash
  45. # define a custom 'delete' command
  46. # cmd delete ${{
  47. # set -f
  48. # printf "$fx\n"
  49. # printf "delete?[y/n]"
  50. # read ans
  51. # [ $ans = "y" ] && rm -rf $fx
  52. # }}
  53. # use '<delete>' key for either 'trash' or 'delete' command
  54. # map <delete> trash
  55. # map <delete> delete
  56. # extract the current file with the right command
  57. # (xkcd link: https://xkcd.com/1168/)
  58. set icons
  59. cmd extract ${{
  60. set -f
  61. case $f in
  62. *.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar xjvf $f;;
  63. *.tar.gz|*.tgz) tar xzvf $f;;
  64. *.tar.xz|*.txz) tar xJvf $f;;
  65. *.zip) unzip $f;;
  66. *.rar) unrar x $f;;
  67. *.7z) 7z x $f;;
  68. esac
  69. }}
  70. # compress current file or selected files with tar and gunzip
  71. cmd tar ${{
  72. set -f
  73. mkdir $1
  74. cp -r $fx $1
  75. tar czf $1.tar.gz $1
  76. rm -rf $1
  77. }}
  78. # compress current file or selected files with zip
  79. cmd zip ${{
  80. set -f
  81. mkdir $1
  82. cp -r $fx $1
  83. zip -r $1.zip $1
  84. rm -rf $1
  85. }}
  86. set previewer lf-ueberzug-previewer
  87. set cleaner lf-ueberzug-cleaner