set shell bash set shellopts '-eu' set info size:time map o open map x extract map t trash map delete map r rename push mw map q push 'w:quit map Q push :quit cmd open ${{ 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 }} # extract files from the selected archive file using # the method based on it's file type. cmd 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 }} # trash moves a file to the trash folder. cmd trash $trash-put $fx # empty-trash empties the trash folder. cmd empty-trash %{{ set -f printf "Are you sure you want to empty the trash? [yes/no] " read ans [ $ans = "yes" ] && trash-empty }} # list-trash list all files and directories in the trash folder. cmd list-trash $trash-list | less # delete permanently deletes a file. cmd delete %{{ set -f printf "Are you sure you want to delete $fx? [yes/no] " read ans [ $ans = "yes" ] && rm -rf $fx }} # vim opens a file in vim. # If the selected file is a directory # the command opens vim in that directory # with an empty buffer. cmd vim ${{ if [ -d $fx ]; then cd $fx && vim else vim $fx fi }} # mkdir creates a new directory cmd mkdir %{{ printf "Directory name: " read ans mkdir $ans }} # mkfile creates a new file cmd mkfile %{{ printf "File name: " read ans touch $ans }} # rename renames a file or folder cmd rename %{{ printf "Enter the new name: " read ans mv $fx $ans }}