summaryrefslogtreecommitdiff
path: root/.local/bin/shortcutgen
blob: 8f4cf6b48eadfb131e4c967c89dc9c9d463dfe01 (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
#!/bin/sh

# Removing unecessary comments and documentation
raw=$(cat $HOME/.config/shortcutrc | tail -n +19 "$HOME/.config/shortcutrc" | sed "s/^|\s*//g;
                                                                              s/\(.*\)|\(.*\)|\(.*\)|/\1|\2|\3/g;
                                                                              s/\s*$//g;
                                                                              /^$/d" | head -n -1)
# #---NERDTREE---# #
echo "$raw" | sed "s/\(.*\)\s*|.*|\s\(.*\)/\1\2/g;
              s/ \{1,\}/ /g;
              s/.HOME/~/g;
              s/-*+-*+-*|//g" > $HOME/.NERDTreeBookmarks

# #---ZSH---# #
# be sure to source $HOME/.cache/zsh-shortcuts in your .zshrc
echo "$raw" | sed 's/^.*|\s\([A-Za-z0-9]*\)\s*|\s\(.*\)$/alias\ g\1="cd\ \2"/g; /^-*+-*+-*|$/d' > $HOME/.cache/zsh-shortcuts

# #---RANGER---# #
# Commands implemented:
# g -> go
# m -> move to...
# t -> new tab
# Y -> copy to...
# 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"
manual=$(sed -n '/Automated Shortcut Generation/q;p' $HOME/.config/ranger/shortcuts.conf)
printf '\n\n# #---Automated Shortcut Generation---#' >> $HOME/.config/ranger/shortcuts.conf
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;
                s/.HOME/~/g;
                s/^-*+-*+-*|$//g' >> $HOME/.config/ranger/shortcuts.conf

# #---ENVIRONMENTAL VARIABLES---# #
echo "$raw" | sed 's/[A-z,a-z,0-9]*\s*|\s*/g/;
                   s/\s*|\s*/=/; s/$/"/;
									 s/-*+-*+.*$//
									 s/^[A-z]*=/\U&/g
									 s/"$//g' > ~/.cache/shell-vars

# #---Vifm---# #
vifm=$(echo "$raw" | sed "
            s/^[A-Z,a-z,0-9]*\s*|//;
						s/\$HOME/~/;
						s/$/<cr>/"
)
vifmcd=$( echo "$vifm" | sed "
				s/^\s*/nnoremap\ g/;
				s/|/:cd/;"
)
vifmv=$( echo "$vifm" | sed "
				s/^\s*/nnoremap\ m/;
				s/|/:move/")
vifmy=$( echo "$vifm" | sed "
				s/^\s*/nnoremap\ y/;
				s/|/:copy/")
echo "$vifmcd\n\n$vifmv\n\n$vifmy" > ~/.cache/vifm-shortcuts

# #---Testing---# #
# echo "$raw" | sed "s/[A-z,a-z,0-9]*\s*|//"

clear
# echo "$vifmv"
cat ~/.cache/vifm-shortcuts