shortcutgen (2273B) - raw


      1 #!/bin/sh
      2 
      3 # Removing unecessary comments and documentation
      4 raw=$(cat $HOME/.config/shortcutrc | tail -n +19 "$HOME/.config/shortcutrc" | sed "s/^|\s*//g;
      5                                                                               s/\(.*\)|\(.*\)|\(.*\)|/\1|\2|\3/g;
      6                                                                               s/\s*$//g;
      7                                                                               /^$/d" | head -n -1)
      8 # #---NERDTREE---# #
      9 echo "$raw" | sed "s/\(.*\)\s*|.*|\s\(.*\)/\1\2/g;
     10               s/ \{1,\}/ /g;
     11               s/.HOME/~/g;
     12               s/-*+-*+-*|//g" > $HOME/.NERDTreeBookmarks
     13 
     14 # #---ZSH---# #
     15 # be sure to source $HOME/.cache/zsh-shortcuts in your .zshrc
     16 echo "$raw" | sed 's/^.*|\s\([A-Za-z0-9]*\)\s*|\s\(.*\)$/alias\ g\1="cd\ \2"/g; /^-*+-*+-*|$/d' > $HOME/.cache/zsh-shortcuts
     17 
     18 # #---RANGER---# #
     19 # Commands implemented:
     20 # g -> go
     21 # m -> move to...
     22 # t -> new tab
     23 # Y -> copy to...
     24 # awk '{print "map g"$1" cd "$2"\nmap t"$1" tab_new "$2"\nmap m"$1" shell mv -v %s "$2"\nmap Y"$1" shell cp -rv %s "$2}' >> "$ranger_shortcuts"
     25 manual=$(sed -n '/Automated Shortcut Generation/q;p' $HOME/.config/ranger/shortcuts.conf)
     26 printf '\n\n# #---Automated Shortcut Generation---#' >> $HOME/.config/ranger/shortcuts.conf
     27 echo "$raw" | sed 's/^.*|\s\(.*\)\s|\s\(.*\)$/map\ g\1\ cd\ \2\nmap\ t\1\ tab_new\ \2\nmap\ m\1\ shell\ mv\ -v\ %s\ \2\nmap\ Y\1\ shell\ cp\ -rv\ %s\ \2\n/g;
     28                 s/.HOME/~/g;
     29                 s/^-*+-*+-*|$//g' >> $HOME/.config/ranger/shortcuts.conf
     30 
     31 # #---ENVIRONMENTAL VARIABLES---# #
     32 echo "$raw" | sed 's/[A-z,a-z,0-9]*\s*|\s*/g/;
     33                    s/\s*|\s*/=/; s/$/"/;
     34 									 s/-*+-*+.*$//
     35 									 s/^[A-z]*=/\U&/g
     36 									 s/"$//g' > ~/.cache/shell-vars
     37 
     38 # #---Vifm---# #
     39 vifm=$(echo "$raw" | sed "
     40             s/^[A-Z,a-z,0-9]*\s*|//;
     41 						s/\$HOME/~/;
     42 						s/$/<cr>/"
     43 )
     44 vifmcd=$( echo "$vifm" | sed "
     45 				s/^\s*/nnoremap\ g/;
     46 				s/|/:cd/;"
     47 )
     48 vifmv=$( echo "$vifm" | sed "
     49 				s/^\s*/nnoremap\ m/;
     50 				s/|/:move/")
     51 vifmy=$( echo "$vifm" | sed "
     52 				s/^\s*/nnoremap\ y/;
     53 				s/|/:copy/")
     54 echo "$vifmcd\n\n$vifmv\n\n$vifmy" > ~/.cache/vifm-shortcuts
     55 
     56 # #---Testing---# #
     57 # echo "$raw" | sed "s/[A-z,a-z,0-9]*\s*|//"
     58 
     59 # clear
     60 # echo "$vifmv"
     61 # cat ~/.cache/vifm-shortcuts