-
Notifications
You must be signed in to change notification settings - Fork 0
/
.custom_commands
executable file
·297 lines (252 loc) · 7.34 KB
/
.custom_commands
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
#!/bin/bash
#a block to reset functions and aliases. functions and aliases were still declared, even when i resourced, so i put this
unset -f greet block_cd ipromiseimdonewithhomework flasher resource codecoms kompile i wordle push-gh goawayZ butthole dingus update finddirs gadd installKotlin cursor installtreesh
aliases=(cde I Wordle dist-info python lsdirfirst lsdirsfirst poo poop poopie upgrade devzat sl ls-a gcommit gpush gpull installkotlin installkt compkot shotcut install uninstall remove reinstall full-upgrade gstatus pacman vimcoms treesheets trsh treesh openurls responsively)
#this array thing is not really neccessary. I could just unalias them all in one command.
for i in ${aliases[@]}; do
unalias ${i} &> /dev/null #forward output to /dev/null - errors from nonexistant aliases are redirected. https://en.wikipedia.org/wiki/Null_device | https://linuxhint.com/what_is_dev_null/
done
#enables commands that are not in any bin dir
#Kotlin, etc
export PATH=".:/home/neriya/Kotlin/kotlinc/bin:/home/neriya/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
function greet() {
if [ ! -z ${1} ]; then
name=" ${1}"
fi
echo "Hello${name}!"
unset name
}
#custom function for custom startup in ~/.bashrc
block_cd() {
echo "you shouldn't do that. You are in HOMEWORK MODE"
#two one line if statements! 119-check if directory has a slash. 120-check if directory was given
#(the second one is second because if it was first it would mess the other one up)
if test a${1::1} != "a/"; then directory="/${1}"; fi #oren suggested the "a" trick. very clever of him
if test -z $1; then directory=~; fi
echo "you cannot go to directory ${directory}"
}
ipromiseimdonewithhomework() {
read -t 2 really
if test "$really" = "i promise"; then
unalias cd
cd ~
else
echo "I solemnly swear you are up to no good!"
fi
}
flasher() { #this is wikipedia's function, formatted by me
while true ; do
printf \\e[?5h #a lot of ansi doesnt work in vscode, such as BEL and this
sleep 0.1
printf \\e[?5l
read -s -n1 -t1 && break #`read` for input - `-s` mutes input (typed characters are not shown) - `-n1` stops after 1 character, regardless of delimiter - `-t1` waits one second
done
}
resource() {
if [ ! -z $1 ]; then
source /$1
echo "resourced $1"
else
source ~/.custom_commands
echo "resourced ~/.custom_commands"
fi
}
codecoms() {
code ~/.custom_commands ~/.bashrc
}
alias vimcoms="vim ~/.custom_commands"
#thankyou() {
# #thank a bunch of people,
# #starting with onmert and working recursively
# #makecode
# #python
# #c
# #etc
# #then other people
# echo "thank you"
#}
#arduino2.0() {
# prevDir=${PWD}
# echo You began in directory ${prevDir}
# cd ~/'Arduino IDE 2.0'
# ./arduino-ide
# cd ${prevDir}
#}
`
#compile and execute kotlin
kompile() {
if [ ! -z ${1} ]; then
if [ ${1} = "-h" ]; then
echo -e "Custom command to compile and execute Kotlin with one command, because the actual command is too long:"
echo -e "Original command: kotlinc source.kt -include-runtime -d result.jar [-verbose]"
echo -e "Custom command usage:"
echo -e "\tcompkot source.kt result.jar [-verbose]"
echo -e "\tkompile source.kt result.jar [-verbose]"
echo -e "[-verbose] applies to both Kotlin compilation *and* Java .jar execution"
echo -e "\nMy puns are superb\t\t\tThis is a custom command, not APT, but my APT has Super Cow Powers\t\t(apt-get moo)"
else
echo -e "\n"
echo -e "Compiling \"${1}\" to \"${2}\""
echo -e "------------------"
#success_list=( "Compilation completed" "------------------" "Executing \"${2}\"" "------------------\n" ) #unused, maybe try again in future
#the command actually executes *inside* the variable, and we grab a variable from it
compilation=$(kotlinc ${1} -include-runtime -d ${2} ${3})
if [ $? = 0 ]; then
#attempt at using array:
#for i in ${success_list}; do
# echo -e ${i}
# sleep 0.2
#done
echo -e "Compilation completed"
sleep 0.1
echo -e "------------------"
sleep 0.1
echo -e "Executing \"./${2}\" via \"java -jar ${2}\""
sleep 0.2
echo -e "------------------\n"
sleep 0.2
java -jar ${3} ${2}
else
echo -e "------------------"
sleep 0.1
echo -e "Compilation failed"
fi
fi
else
echo "Please include a Kotlin file to be compiled, and the path of the resulting .jar file."
echo "Alternatively, append \`-h\` to this command for usage help"
fi
}
`
alias compkot="kompile"
alias cde="code"
i() {
firstarg=${1}
shift
if [ ! -z ${firstarg} ]; then
if [ ${firstarg} = "am" ]; then
echo "Ah, you are ${@}"
elif [ ${firstarg} = "want" ]; then
echo "Well, you can't have ${@}"
echo "At least not right now."
elif [ ${firstarg} = "should" ]; then
echo "Yes you certainly should ${@}"
echo "You clearly know that."
echo "Now go do it"
fi
else
echo "you"
fi
}
alias I="i"
wordle() {
python3 ~/Python/wordle.py ${@}
}
alias Wordle="wordle"
alias dist-info="cat /etc/os-release"
alias python="python3"
push-gh() {
git add .
git commit -m "${1}"
git push
}
alias lsdirfirst="ls --group-directories-first"
alias lsdirsfirst="ls --group-directories-first"
#Why do I have to do this?
goawayZ() {
echo -e "\e[5mZECHARYA -- GO AWAY! You are not welcome here\e[0m"
}
alias poo="goawayZ"
alias poop="goaway"
alias poopie="goawayZ"
butthole() {
echo "(Have you checked up your)"
goawayZ
}
dingus() {
echo "is what you are"
goawayZ
}
update() {
date
cursor
printf "\e[?25l"
echo -e "--> updating\n"
sudo apt update
echo -e "\n--> upgrading\n"
sudo apt upgrade
cursor
}
alias upgrade="sudo apt upgrade"
alias devzat="ssh [email protected]"
finddirs() {
find . -maxdepth 1 -name "${1}" -type d
}
installKotlin() {
sudo chmod u+x ~/Kotlin/kotlinc/bin/*
}
alias installkotlin="installKotlin"
alias installkt="installKotlin"
alias sl="sl -e "
alias ls-a="ls -a"
gadd() {
if [ ! -z ${1} ]; then
git add ${1} --verbose
else
git add . --verbose
fi
}
alias gcommit="git commit --verbose"
alias gpush="git push --verbose"
alias gpull="git pull --verbose"
alias gstatus="git status"
#i switched video editors -- actually, never actually used kdenlive
alias shotcut="shotcut.AppImage"
alias install="sudo apt install"
alias uninstall="sudo apt remove"
alias remove="sudo apt remove"
alias reinstall="sudo apt reinstall"
alias full-upgrade="sudo apt full-upgrade"
cursor() {
#`[` is giving me a headache:
# if [ ! -z ${1} && ${1,,} == "show" || [ ! -n {1} ] && ${CURSOR} == "FALSE" ]; then
# printf "\e[?25h"
# CURSOR="TRUE"
# export CURSOR
# elif [ ! -z ${1} ] && ${1,,} == "hide" || [ ! -n {1} ] && ${CURSOR} == "TRUE" ]; then
# printf "\e[?25l"
# CURSOR="FALSE"
# export CURSOR
# fi
if [ ! -z ${1} ]; then
if [ ${1,,} = "show" ]; then
printf "\e[?25h"
CURSOR="TRUE"
export CURSOR
elif [ ${1,,} = "hide" ]; then
printf "\e[?25l"
CURSOR="FALSE"
export CURSOR
fi
else
if [ ${CURSOR} = "TRUE" ]; then
printf "\e[?25l"
CURSOR="FALSE"
export CURSOR
else
printf "\e[?25h"
CURSOR="TRUE"
export CURSOR
fi
fi
}
#not to be confused with Arch package manager
alias pacman="pacman4console"
alias treesheets="/home/neriya/strlen/treesheets_src/treesheets"
alias trsh="treesheets"
alias treesh="treesheets"
installtree() {
chmod +x /home/neriya/strlen/treesheets_src/treesheets
}
alias openurls="ghups"
alias responsively="Responsively.AppImage"