-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdot_aliases
513 lines (440 loc) · 16.1 KB
/
dot_aliases
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
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
#################################################################################################################################################
#################################################################################################################################################
#####################################
##################################### Bash Aliases. Feike Li 2020.5.2 ver
##################################### write some documentation formatting here:
#####################################
##################################### 1.temp aliases
##################################### 2.system aliases
##################################### 3.applications
#####################################
#####################################
#################################################################################################################################################
#################################################################################################################################################
#----------------------
# temp alias
#----------------------
alias mm="cd /home/feeco/Documents/fag && ranger "
alias server="ssh -i ~/Documents/lifeike/7.2022/7.aws/3.windows-server-instance/feeco.pem ubuntu@ec2-100-25-197-123.compute-1.amazonaws.com"
#---------------------
# system aliases
#---------------------
alias l='ls -lh'
alias f='tmux a'
alias c='clear'
alias h='cd $HOME && clear'
alias q='exit'
alias k='sudo killall '
alias w='curl wttr.in/calgary?1'
alias n='sudo n'
alias e='gedit '
alias p='vim ~/Documents/feeco/1.lifeike/password.txt'
alias d='cd /home/feeco/Downloads && ranger'
alias document='cd /home/feeco/Documents && ranger'
alias gg='cd /home/feeco/ZGoogleDrive && ranger'
alias desktop='cd /home/feeco/Desktop && ranger'
alias music='cd /home/feeco/Music && ranger'
alias video='cd /home/feeco/Videos && ranger'
alias pan='cd /home/feeco/ZcloudDisk && ranger'
alias picture='cd /home/feeco/Pictures && ranger'
alias install='sudo apt install -y'
alias remove='sudo apt purge -y'
alias tree='tree -a'
alias screenoff='gsettings set org.gnome.desktop.session idle-delay'
alias process='ps -ef | grep'
alias biggestFile='find . -type f -exec du -h {} + | sort -hr | head -20'
alias ds='ncdu ~'
alias s='cdf'
alias a="alsamixer"
alias download='aria2c'
alias t='phind_chat'
# generate types based on swagger
alias generateTypes='npx openapi-typescript@5.4.1 https://api.uat.pulsepointsoftware.com/swagger/v1/swagger.json --output types.v3.ts'
# use phind
function phind_chat(){
echo "Press enter to exit..."
# loop until the user presses enter
while true; do
echo "======================================================================================================================================"
echo "======================================================================================================================================"
read -p "Search with phind: " userInput
clear
tgpt "$userInput"
# check if the user pressed enter without typing anything else
if [ -z "$userInput" ]; then
break
fi
done
echo "Exiting..."
}
# port in used.
alias portinused='lsof -i -P -n'
alias data='vnstat'
ip(){
echo "==========="
echo "signal strength"
echo "-67 dBm Reliable signal strength."
echo "-70 dBm Not a strong signal."
echo "-80 dBm Unreliable signal strength, will not suffice for most services."
echo "-90 dBm The chances of even connecting are very low at this level."
iwconfig
echo "==========="
echo "signal information"
ifconfig
}
# explain commands
alias m='tldr -u && tldr'
#mark current directory as mm
mark(){
dir=$PWD
#sed -i "5s|.*|\"$dir\"|g" ~/Desktop/a.txt
sed -i "18s|.*|alias mm=\"cd $dir \&\& ranger \"|g" ~/.aliases
load_resource_rcfiles
}
#-------------------------------
# unzip unrar
#-------------------------------
alias unrarall='for file in *.rar; do unrar e -p "$file"; done'
alias unzipgarbled='unzip -O cp936 ' #unzip and solve garbled issue
look() {
if [ $# -eq 0 ]; then
echo "Please provide a domain name."
return 1
fi
local domain="$1"
# whois "$domain" | less
whois "$domain" | \
awk '/Creation Date/ {print "\033[31m" $0 "\033[0m"} {print}' | \
less -R
}
#-------------------------------
# wechat 微信
#-------------------------------
## 运行微信
alias wechat-start='singularity exec -B /run /opt/wechat.sif /opt/apps/com.qq.weixin.deepin/files/run.sh'
# 唤出已运行的WeChat窗口
alias wechat='singularity exec /opt/wechat.sif /opt/deepinwine/tools/sendkeys.sh w wechat 4'
# 微信截图
alias wechat-screenshot='singularity exec /opt/wechat.sif /opt/deepinwine/tools/sendkeys.sh a wechat 3'
# 退出微信
alias wechat-quit="singularity exec /opt/wechat.sif /opt/deepinwine/tools/kill.sh wechat"
#-------------------------------
# brightness
#-------------------------------
#get monitors you're using: xrandr | grep " connected" | cut -f1 -d " "
#change the brightness level: xrandr --output eDP-1 --brightness 0.2
alias 1="echo 1 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1 "
alias 2="echo 100 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1 "
alias 3="echo 200 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1 "
alias 4="echo 300 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1 "
alias 5="echo 400 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1 "
alias 6="echo 500 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1 "
alias 7="echo 600 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1 "
alias 8="echo 700 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1 "
alias 9="echo 800 | sudo tee /sys/class/backlight/intel_backlight/brightness > /dev/null && xrandr --output eDP-1 --brightness 1.2 "
#-------------------------------
# sound volume
#-------------------------------
alias 11='amixer sset "Master" 10%'
alias 22='amixer sset "Master" 20%'
alias 33='amixer sset "Master" 30%'
alias 44='amixer sset "Master" 40%'
alias 55='amixer sset "Master" 50%'
alias 66='amixer sset "Master" 60%'
alias 77='amixer sset "Master" 70%'
alias 88='amixer sset "Master" 80%'
alias 99='amixer sset "Master" 90%'
alias 00='amixer sset "Master" 100%'
alias soundRestart='pulseaudio -k && sudo alsa force-reload'
#-------------------------------
# add color to command output
#-------------------------------
execute_command_cyan(){
#execute the passed command and capture its output
local output=$(eval "$1")
#print output in red color
echo -e "\033[36m$output\033[0m"
}
#-------------------------------
# fzf
#-------------------------------
alias pdf='cd $HOME && zathura --mode fullscreen "$(fzf)" '
#find file and navigate to the directory
ff(){
cd $HOME
file=$(fzf -q "$1")
dir=$(dirname "$file")
ranger "$dir"
}
#-------------------------------
# chrome
#-------------------------------
updateChrome(){
cd $HOME
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
rm google-chrome-stable_current_amd64.deb
}
function alternative(){
google-chrome https://alternativeto.net/software/$1/?platform=linux&sort=likes
}
#-------------------------------
# file formatting
#-------------------------------
# covert all pdf to text file in the current folder/directory
alias convertallpdf='ls *.pdf | xargs -n1 pdftotext'
# covert all pdf to png file in the current folder/directory
alias convertallpdftopng=allpdftopng
function allpdftopng(){
for file in *.pdf;
do pdftoppm "$file" "$file";
done
}
# convert ppt to pdf
alias convertpptxtopdf='libreoffice --headless --invisible --convert-to pdf *.pptx'
# convert doc/docx to text
alias convertdocxtotxt='libreoffice --headless --convert-to txt'
# convert images to pdf
alias convertjpgtopdf='convert *.jpg output.pdf'
#---------------------
# applications
#---------------------
#nodejs npm
alias ni='npm install && npm run start'
alias nb='npm run build '
#alias code='code -r -n '
#leetcode-cli
alias leetcode='nvm use lts\/erbium && leetcode'
#generate source file and put description in the source and select language as javascript
alias generate=leetcode_generate
function leetcode_generate(){
local input=$1;
cd /home/feeco/Documents/lifeike/0.leetcode;
nvm use lts/erbium;
leetcode show $input -gxe -l javascript;
}
alias submit=leetcode_submit
function leetcode_submit(){
local input=$1;
cd /home/feeco/Documents/lifeike/0.leetcode;
nvm use lts/erbium;
leetcode submit $input ;
}
alias status=leetcode_status
function leetcode_status(){
cd /home/feeco/Documents/lifeike/0.leetcode;
nvm use lts/erbium;
leetcode list -s;
leetcode stat;
}
#list all app installed manually
alias installed=manually_installed
function manually_installed(){
comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
}
#update and upgrade packages
alias update=updateall
function updateall(){
sudo apt upgrade;
sudo apt-get upgrade;
sudo apt update;
sudo apt-get update;
updateChrome;
sudo snap refresh;
python3 -m pip install -U yt-dlp;
sudo apt-get clean;
sudo apt clean;
sudo apt autoremove;
sudo apt-get autoremove;
sudo apt-get autoclean;
sudo apt autoclean;
}
function clean(){
sudo apt-get clean;
sudo apt clean;
sudo apt autoremove;
sudo apt-get autoremove;
sudo apt-get autoclean;
sudo apt autoclean;
}
# apps
alias v='vim'
alias r='ranger'
##########################
# youtube-dl
##########################
#alias youtubedownloadmp3='youtube-dl -xiwc --audio-format mp3 '
#alias youtube='youtube-dl -o "%(title)s.%(ext)s"'
alias youtubesubtitle='youtube-dl --sub-lang en --convert-subs srt --write-sub'
##########################
# mpv
###########################
alias mp3='mpv --no-video '
##########################
# yt-dlp
###########################
alias youtubedownloadmp3='youtube -xiwc --audio-format mp3 '
alias youtube='yt-dlp -o "%(title)s.%(ext)s"'
# load all source files
alias load='source ~/.bashrc'
#########################
# tmux
#########################
# open tmux fullscreen with sessions attached
alias tnew=createNewSessionInsideTmuxSession
function createNewSessionInsideTmuxSession(){
session_name=$1
# 1. First you check if a tmux session exists with a given name.
tmux has-session -t=$session_name 2> /dev/null
# 2. Create the session if it doesn't exists.
if [[ $? -ne 0 ]]; then
TMUX='' tmux new-session -d -s "$session_name"
fi
# 3. Attach if outside of tmux, switch if you're in tmux.
if [[ -z "$TMUX" ]]; then
tmux attach -t "$session_name"
else
tmux switch-client -t "$session_name"
fi
}
alias tkill=killTmuxSession
function killTmuxSession(){
tls;
IFS= read -r -p "input session name: " sessionName
tmux switch-client -t main && #switch to main session before target session killed
tmux kill-session -t "$sessionName" ;
}
#main session layout
alias layout=defaultLayout
function defaultLayout(){
tmux selectp -t 0;
tmux splitw -v -p 40; #split vertically
tmux splitw -h -p 50;
tmux splitw -v -p 50;
tmux selectp -t 1; #select pane number 1
tmux splitw -v -p 50;
tmux send-keys -t2 music Enter ;
tmux send-keys -t2 ranger Enter ;
tmux send-keys -t4 "cd ~/Downloads" Enter ;
tmux selectp -t 0;
}
#project session layout
alias project=projectLayout
function projectLayout(){
tmux selectp -t 0;
tmux splitw -v -p 60; #split vertically
tmux splitw -h -p 50;
tmux selectp -t 0;
}
#----------------------------
# application github
#----------------------------
alias lifeike='cd /home/feeco/Documents/feeco && gb && gs && ranger'
alias gb='git branch --sort=committerdate | column'
alias gitlastcommit='git diff HEAD^ '
alias gitcommitscount='git shortlog -sn --all'
alias gitlistconflicts='git diff --check'
alias gittodolist='gh issue list'
alias gittodo='gh issue create'
# git status
function gs(){
echo "==========================================================="
git status
# echo -e "\n" # empty line
execute_command_cyan pwd
}
#git tags
alias gt='echo "local tags: " && git tag -n && echo "" && echo "" && echo "remote tags: " && git ls-remote --tags'
alias gnewtag='git tag -a' #append the tag name after
#list all conflict files
alias gitconflict='git diff --name-only --diff-filter=U'
#alias gl='git log -20 --abbrev-commit --pretty=oneline --graph'
alias gl='git log -20 --graph --abbrev-commit --decorate=no --date=format:"%m-%d %H:%M" --format=format:"%C(03)%>|(15)%h%C(reset) %an%C(reset) %C(04)%ad%C(reset) %s%C(reset) %C(bold 1)%d%C(reset) %C(reset)" --all'
alias gitbigfile='git rev-list --all | xargs -rL1 git ls-tree -r --long | sort -uk3 | sort -rnk4 | head -10'
# git discard all local changes and remove all untracked files(new files)
alias gr='git reset --hard && git clean -fd'
# open a git project then open source code in vscode then run this project
alias open=git-open-project
function git-open-project(){
git-clone-all-branches $1 && code -r . && npm install && npm run start
}
# clone a git repo with all remote branches
alias gc=git-clone-all-branches
function git-clone-all-branches(){
#go to source code folder
git clone $1
basename=$(basename $1)
filename=${basename%.*}
cd $filename
#clone all remote branches from remote
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do
#rename remote branches to local branch( remotes/origin/hello --> hello )
git branch --track ${branch##remotes/origin/} $branch
done
}
# gcot - git checkout branch/tag
ggb() {
local tags branches target
tags=$(
git tag | awk '{print "\x1b[31;1mtag\x1b[m\t" $1}') || return
branches=$(
git branch --all | grep -v HEAD |
sed "s/.* //" | sed "s#remotes/[^/]*/##" |
sort -u | awk '{print "\x1b[34;1mbranch\x1b[m\t" $1}') || return
target=$(
(echo "$tags"; echo "$branches") |
fzf-tmux -- --no-hscroll --ansi +m -d "\t" -n 2) || return
git checkout $(echo "$target" | awk '{print $2}')
}
alias gp='pushall'
function pushall(){
#read -p 'commit message: ' commitMessage
IFS= read -r -p "commit message: " commitMessage
git add -A;
git commit --allow-empty -am "$commitMessage";
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
git push -u origin $branch
clear
}
#-----------------
# npm + mongodb
#-----------------
alias npminstalled='npm list --global --depth=0'
alias mongo='mongosh "mongodb+srv://cluster0.de2gw.mongodb.net/myFirstDatabase" --username feeco --password Test@1234'
#-----------------
# ffmpeg
#-----------------
# merge video with subtitles
alias combinevideosubtitle=combine_video_and_subtitles
function combine_video_and_subtitles(){
ffmpeg -i $1 -i $2 -c:s mov_text -c:v copy -c:a copy output.mp4
}
# split video into 10 mins clip
# ffmpeg -i fff.avi -acodec copy -f segment -segment_time 10 -vcodec copy -reset_timestamps 1 -map 0 fff%d.avi
alias splitvideo='split_big_video_into_clips_of_10mins'
function split_big_video_into_clips_of_10mins(){
local input=$1;
ffmpeg -i $1 -acodec copy -f segment -segment_time 600 -vcodec copy -reset_timestamps 1 -map 0 $1%d.avi
}
#-----------------
# fuzzy finder
#-----------------
# cdf - cd into the directory of the selected file
cdf() {
cd ~
local file
local dir
file=$(fzf +m -q "$1") && dir=$(dirname "$file")
ranger "$dir"
pwd
#file=$(fzf +m -q "$1") && dir=$(dirname "$file") && cd "$dir"
}
alias vf='cd $HOME && vim $(fzf)'
#-----------------
# chezmoi
#-----------------
alias update-dotfiles='chezmoi re-add'
alias sync-dotfiles='chezmoi update'
alias cd-dotfiles='cd ~/.local/share/chezmoi && ranger'
alias add-dotfiles='chezmoi add'
alias cs='chezmoi status'