forked from patrickcjh/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.bash_aliases
111 lines (105 loc) · 3.31 KB
/
.bash_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
shopt -s expand_aliases
alias ls='ls --color=auto'
alias sl='ls'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias dua='du -sch .[!.]* * |sort -h'
alias vimod='set -o vi'
alias novimod='set -o emacs'
alias start='xdg-open'
alias open='xdg-open'
alias ssh-basic='ssh -X -A -L 8080:localhost:80'
alias ssh-onetime='ssh -X -A -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o StrictHostKeyChecking=no'
alias sftp-onetime='sftp -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR -o StrictHostKeyChecking=no'
alias ssh='ssh -X -A'
alias vimg='vim -c GV -c "silent! G" -c "silent! tabonly"'
alias catkin_make_compile_commands='catkin_make -DCMAKE_EXPORT_COMPILE_COMMANDS=1'
alias watchexec='f(){ watch -n1 "watch -t -g ls --full-time \"$1\" >/dev/null && $2"; unset -f f;}; f'
alias ssh-start-agent='eval $(keychain --eval ~/.ssh/<your_key>)'
alias ssh-agent-start='eval "$(ssh-agent)"'
alias timesync='if grep -qE "(Microsoft|WSL)" /proc/version &>/dev/null; then sudo hwclock -s; else sudo timedatectl set-ntp off && sudo timedatectl set-ntp on; fi'
# alias fvim='NVIM_APPNAME=fvim nvim'
# alias fvimg='NVIM_APPNAME=fvim nvim -c GV -c "silent! G" -c "silent! tabonly"'
# windows (wsl) specific
alias pwsh='powershell -Command'
_get_vm_status()
{
params=''
for arg in "$@"
do
if [ -n "$params" ]
then
params="$params,"
fi
params="$params\"$arg\""
done
echo "$(pwsh get-vm \| where-object\{\$_.state -in \@\($params\)\} \| select-object -expand name | tr -d "\r")"
}
_pwsh()
{
local cur prev
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
case ${COMP_CWORD} in
1)
COMPREPLY=($(compgen -W "get-vm start-vm stop-vm suspend-vm save-vm resume-vm vmconnect choco sudo winget ipconfig" -- ${cur}))
;;
2)
case ${prev} in
start-vm)
COMPREPLY=($(compgen -W "$(_get_vm_status off saved)" -- ${cur}))
;;
stop-vm)
COMPREPLY=($(compgen -W "$(_get_vm_status running)" -- ${cur}))
;;
suspend-vm)
COMPREPLY=($(compgen -W "$(_get_vm_status running)" -- ${cur}))
;;
save-vm)
COMPREPLY=($(compgen -W "$(_get_vm_status running)" -- ${cur}))
;;
resume-vm)
COMPREPLY=($(compgen -W "$(_get_vm_status paused)" -- ${cur}))
;;
vmconnect)
COMPREPLY=($(compgen -W "localhost" -- ${cur}))
;;
sudo)
COMPREPLY=($(compgen -W "choco" -- ${cur}))
;;
choco)
COMPREPLY=($(compgen -W "search find info" -- ${cur}))
;;
winget)
COMPREPLY=($(compgen -W "install show search upgrade uninstall import export" -- ${cur}))
;;
esac
;;
3)
case ${COMP_WORDS[1]} in
sudo)
case ${prev} in
choco)
COMPREPLY=($(compgen -W "search find info install uninstall upgrade" -- ${cur}))
;;
esac
;;
vmconnect)
case ${prev} in
localhost)
COMPREPLY=($(compgen -W "$(pwsh get-vm \| select-object -expand name | tr -d "\r")" -- ${cur}))
;;
esac
;;
esac
;;
*)
COMPREPLY=()
;;
esac
}
complete -F _pwsh pwsh