-
Notifications
You must be signed in to change notification settings - Fork 0
/
_aliases
154 lines (133 loc) · 3.29 KB
/
_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
#!/bin/zsh -f
# FILE SYSTEM
alias cp='cp -i'
alias mv='mv -i'
alias ls='gls --color=auto'
alias homer='cd ~/code/random'
alias changemac="sudo ifconfig en0 ether $(openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//')"
updatedb() {
(cd / && sudo /usr/libexec/locate.updatedb)
}
## EMACS
alias start_emacs='emacs --daemon'
alias kill_emacs='emacsclient -e "(kill-emacs)"'
export EDITOR="emacsclient -t"
e() {
(emacsclient $1 -c &)
}
alias et='emacsclient -t'
# swap two files/folders
swap() {
local timestamp=$(date "+%s")
mv "$1" "$1.$timestamp"
mv "$2" "$1"
mv "$1.$timestamp" "$2"
}
function sush {
ssh -At $1 sudo su
}
## GIT HELPERS
function get_trunk {
git remote show origin | sed -n '/HEAD branch/s/.*: //p'
}
alias gtu='gh pr create --draft'
alias git-undo-wp-changes='git diff -U0 -w --no-color | git apply --cached --ignore-whitespace --unidiff-zero -'
function gitsummary() {
for dot_git in $(find ~/code -name .git -maxdepth 2 | sort); do
repo_root="$(dirname "${dot_git}")"
repo_name="$(basename "${repo_root}")"
printf "%srepo: %s%s%s" $'\033[1;31m' $'\033[1;34m' $'\033[0m' "${repo_name}"
branches="$(git -C "${repo_root}" branch | grep -v "^[\* ] main$" | grep -v "^[\* ] master$")"
if [ "$(echo -n "$branches" | wc -l)" -lt 1 ]; then
printf "\n\n"
continue
else
printf "\n%s\n\n" "$branches"
fi
done
}
function gitr {
trunk="$(get_trunk)"
git checkout "$trunk"
git pull origin "$trunk"
git checkout -
gst sync
}
function gitb {
if [ -z "$1" ]; then
echo "Missing branch name"
return 1
fi
datestring="$(date +"%Y%m%d")"
new_branch_name="$datestring-$1"
from_branch="$2"
if [ -z "$from_branch" ]; then
from_branch="$(get_trunk)"
fi
if command -v gst &>/dev/null; then
gst b "$new_branch_name" "$from_branch"
else
if [[ "$from_branch" == "." ]]; then
from_branch="$(git rev-parse --abbrev-ref HEAD)"
fi
git switch -c "$new_branch_name" "$from_branch" "${@:3}"
fi
}
## KUBERNETES
alias k='kubectl'
## TERRAFORM
alias tf='terraform'
alias tfa='terraform apply'
alias tfc='terraform console'
alias tfi='terraform init'
alias tfim='terraform import'
alias tfp='terraform plan'
## VIDEO GAME HELPERS
function factorio_upload {
cp "~/Library/Application Support/factorio/saves/$1.zip" "/Volumes/GoogleDrive/My Drive/Personal/factorio-saves/"
}
function dont_starve_upload {
destination=$(date "+%Y-%m-%d")
cp -r "~/Library/Application Support/Steam/userdata/1021426716/219740/remote" "/Volumes/GoogleDrive/My Drive/Personal/dont-starve-saves/$destination"
}
function fix_itb {
sed -i 'bkp' 's/\["iUndoTurn"\] = 0/["iUndoTurn"] = 1/g' ~/Library/Application\ Support/IntoTheBreach/profile_Alpha/saveData.lua
}
function man() {
env \
LESS_TERMCAP_mb=$(
tput bold
tput setaf 1
) \
LESS_TERMCAP_md=$(
tput bold
tput setaf 208
) \
LESS_TERMCAP_me=$(tput sgr0) \
LESS_TERMCAP_so=$(
tput bold
tput setaf black
tput setab 3
) \
LESS_TERMCAP_se=$(
tput rmso
tput sgr0
) \
LESS_TERMCAP_us=$(
tput smul
tput dim
tput setaf 7
) \
LESS_TERMCAP_ue=$(
tput rmul
tput sgr0
) \
LESS_TERMCAP_mr=$(tput rev) \
LESS_TERMCAP_mh=$(tput dim) \
LESS_TERMCAP_ZN=$(tput ssubm) \
LESS_TERMCAP_ZV=$(tput rsubm) \
LESS_TERMCAP_ZO=$(tput ssupm) \
LESS_TERMCAP_ZW=$(tput rsupm) \
PAGER="less -s -M +Gg" \
man "$@"
}