summaryrefslogtreecommitdiff
path: root/sh/functions
blob: 3c73fb70d03cc2c91beb5d54ed1312cfc8f34991 (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
#!/bin/sh
catclip () {
	cat $@ | xclip -selection clipboard
}

catpass () {
	PASSWD=$(cat ~/pass.txt); echo "$PASSWD\n$PASSWD" | pass insert "$1"; unset PASSWD
}

mpt () {
  for i in $@; do
    echo "" > $i
  done
}

mkcd () {
  mkdir -p $@ && cd $1
}

ntharg () {
  shift $1
  printf '%s\n' "$1"
}

mvcd () {
  mv $@ && cd `ntharg $# "$@"`
}

if [[ "$SHELL" =~ .*zsh$ ]]; then
  zshaddhistory () {
    emulate -L zsh
    if [[ $1 != *"veracrypt"* ]]; then
      print -sr -- "${1%%$'\n'}"
      fc -p
    else
      return 1
    fi
  }
fi

scd () {
  if [ "$1" = "" ]; then
    cd $HOME
  else
    case "$1" in
      "-h")
      # STARTPRINT
echo "scd - a script to change directories based on shortcuts.
E.	- /etc
O.	- /opt
Oa	- /opt/Audio Assault
R	- /
U.	- /usr
Us	- /usr/share
V.	- /var
aw	- /home/zachir/.config/awesome
b.	- /home/zachir/.local/bin
bb	- /home/zachir/.local/bin/blocks
bf	- /home/zachir/.local/bin/slatpak-sc
bg	- /home/zachir/.local/bin/generics
bi	- /home/zachir/.local/bin/ignore
bsc	- /home/zachir/.local/bin/scripts
bsh	- /home/zachir/.local/bin/shortcmds
bsp	- /home/zachir/.local/bin/sp
c	- /home/zachir/.config
db	- /home/zachir/.local/src/dwmbar
dc	- /home/zachir/Documents
dl	- /home/zachir/.local/src/dwl
dm	- /home/zachir/.local/src/dmenu
do	- /home/zachir/Downloads
dp	- /home/zachir/Downloads/plugin/zachir_librem.one
dw	- /home/zachir/Downloads/wine
e	- /home/zachir/Desktop
f	- /home/zachir/.var/app
h	- /home/zachir/.config/hypr
lb	- /home/zachir/.local/bin
lc	- /home/zachir/Games/cache
lf	- /home/zachir/.config/lf
ls	- /home/zachir/.local/share
n3	- /home/zachir/.vst3/native
ns	- /home/zachir/.vst/native
nv	- /home/zachir/.config/nvim
p	- /home/zachir/Pictures
qb	- /home/zachir/.config/qutebrowser
qp	- /home/zachir/.local/share/qutebrowser-profiles
re	- /home/zachir/.local/src
rs	- /etc/runit/sv
sc	- /home/zachir/.local/bin/scripts
sh	- /home/zachir/.config/sh
sl	- /home/zachir/.local/src/slock
ss	- /etc/s6/sv
st	- /home/zachir/.local/src/st
sx	- /home/zachir/.config/sxhkd
tr	- /home/zachir/.local/share/Trash/files
urs	- /home/zachir/.runit/sv
v3.	- /home/zachir/.vst3
v3n	- /home/zachir/.vst3/native
v3y	- /home/zachir/.vst3/yabridge
v.	- /home/zachir/var
vi	- /home/zachir/Videos
vsn	- /home/zachir/.vst/native
vs.	- /home/zachir/.vst
vsy	- /home/zachir/.vst/yabridge
wdo	- /home/zachir/.local/share/wineprefixes/default/drive_c/users/zachir/Downloads
wa	- /home/zachir/.local/src/wallpapers
wd	- /home/zachir/.local/share/wineprefixes/default
wr	- /home/zachir/.local/share/wineprefixes
wv3	- /home/zachir/.winvst3
wvs	- /home/zachir/.winvst
ww	- /home/zachir/.local/share/wineprefixes/work
x	- /home/zachir/.config/X11
y3	- /home/zachir/.vst3/yabridge
yb	- /home/zachir/.cache/yay
yc	- /home/zachir/.config/yay
zs	- /home/zachir/.config/zsh
zx	- /home/zachir/Documents/zachir.xyz
" ;;
      # STOPPRINT
      # STARTPATHS
"E.") cd "/etc" ;;
"O.") cd "/opt" ;;
"Oa") cd "/opt/Audio Assault" ;;
"R") cd "/" ;;
"U.") cd "/usr" ;;
"Us") cd "/usr/share" ;;
"V.") cd "/var" ;;
"aw") cd "$XDG_CONFIG_HOME/awesome" ;;
"b.") cd "$HOME/.local/bin" ;;
"bb") cd "$HOME/.local/bin/blocks" ;;
"bf") cd "$HOME/.local/bin/slatpak-sc" ;;
"bg") cd "$HOME/.local/bin/generics" ;;
"bi") cd "$HOME/.local/bin/ignore" ;;
"bsc") cd "$HOME/.local/bin/scripts" ;;
"bsh") cd "$HOME/.local/bin/shortcmds" ;;
"bsp") cd "$HOME/.local/bin/sp" ;;
"c") cd "$XDG_CONFIG_HOME" ;;
"db") cd "$SRCDIR/dwmbar" ;;
"dc") cd "$XDG_DOCUMENTS_DIR" ;;
"dl") cd "$SRCDIR/dwl" ;;
"dm") cd "$SRCDIR/dmenu" ;;
"do") cd "$XDG_DOWNLOAD_DIR" ;;
"dp") cd "$XDG_DOWNLOAD_DIR/plugin/zachir_librem.one" ;;
"dw") cd "$XDG_DOWNLOAD_DIR/wine" ;;
"e") cd "$XDG_DESKTOP_DIR" ;;
"f") cd "$HOME/.var/app" ;;
"h") cd "$XDG_CONFIG_HOME/hypr" ;;
"lb") cd "$HOME/.local/bin" ;;
"lc") cd "$HOME/Games/cache" ;;
"lf") cd "$XDG_CONFIG_HOME/lf" ;;
"ls") cd "$XDG_DATA_HOME" ;;
"n3") cd "$HOME/.vst3/native" ;;
"ns") cd "$HOME/.vst/native" ;;
"nv") cd "$XDG_CONFIG_HOME/nvim" ;;
"p") cd "$XDG_PICTURES_DIR" ;;
"qb") cd "$XDG_CONFIG_HOME/qutebrowser" ;;
"qp") cd "$XDG_DATA_HOME/qutebrowser-profiles" ;;
"re") cd "$SRCDIR" ;;
"rs") cd "/etc/runit/sv" ;;
"sc") cd "$HOME/.local/bin/scripts" ;;
"sh") cd "$XDG_CONFIG_HOME/sh" ;;
"sl") cd "$SRCDIR/slock" ;;
"ss") cd "/etc/s6/sv" ;;
"st") cd "$SRCDIR/st" ;;
"sx") cd "$XDG_CONFIG_HOME/sxhkd" ;;
"tr") cd "$XDG_DATA_HOME/Trash/files" ;;
"urs") cd "$HOME/.runit/sv" ;;
"v3.") cd "$HOME/.vst3" ;;
"v3n") cd "$HOME/.vst3/native" ;;
"v3y") cd "$HOME/.vst3/yabridge" ;;
"v.") cd "$HOME/var" ;;
"vi") cd "$XDG_VIDEOS_DIR" ;;
"vsn") cd "$HOME/.vst/native" ;;
"vs.") cd "$HOME/.vst" ;;
"vsy") cd "$HOME/.vst/yabridge" ;;
"wdo") cd "$WINEPREFIX/drive_c/users/$USER/Downloads" ;;
"wa") cd "$SRCDIR/wallpapers" ;;
"wd") cd "$WINEPREFIX" ;;
"wr") cd "$WINEROOT" ;;
"wv3") cd "$HOME/.winvst3" ;;
"wvs") cd "$HOME/.winvst" ;;
"ww") cd "$WINEROOT/work" ;;
"x") cd "$XDG_CONFIG_HOME/X11" ;;
"y3") cd "$HOME/.vst3/yabridge" ;;
"yb") cd "$XDG_CACHE_HOME/yay" ;;
"yc") cd "$XDG_CONFIG_HOME/yay" ;;
"zs") cd "$XDG_CONFIG_HOME/zsh" ;;
"zx") cd "$XDG_DOCUMENTS_DIR/zachir.xyz" ;;
      # STOPPATHS
      *) echo "\"$1\" is not a known location" ;;
    esac
  fi
}