-
Notifications
You must be signed in to change notification settings - Fork 3
/
.linux-gnu-custom-settings
executable file
·408 lines (363 loc) · 13.2 KB
/
.linux-gnu-custom-settings
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
#!/bin/bash
##################################
# SHELL CUSTOM SETTINGS: ZSHELL
#
# This file should be used only in
# linux-gnu* OS environments.
#
# References:
# - https://stackoverflow.com/a/20983251
# - https://linuxconfig.org/the-best-linux-terminal-color-schemes-for-2019
# - https://invisible-island.net/xterm/
# - https://linuxhint.com/ls_colors_bash/
# - http://www.bigsoft.co.uk/blog/2008/04/11/configuring-ls_colors
# - http://supercat.nosredna.net/
##################################
###################
# ALIASES
###################
# General
alias c="currentDir"
alias gt="goToDir"
alias lls="longls ${1}"
alias xclip="xclip -selection clipboard"
alias expath="export PATH=$PATH:$(pwd)"
alias grep="grep --no-messages --color=auto --exclude-dir=.bzr --exclude-dir=CVS --exclude-dir=.git --exclude-dir=.idea --exclude-dir=vendor --exclude=tags --exclude='*.log'"
# git
alias gc="git commit -S -v"
alias gdsafe="git branch --merged | egrep -v '(main|master|develop|^\*)' | xargs git branch -D"
alias gdall="git branch | egrep -v '(main|master|develop|^\*)' | xargs git branch -D"
alias gst="git status -u"
alias gsl="git stash list"
alias glu="git ls-files --others --exclude-standard"
alias gsp="git stash -p"
# Docker
alias dbbk="DOCKER_BUILDKIT=1 docker build"
alias db="docker build"
alias drmi="docker rmi ${1} -f"
alias dddi="docker images --filter \"dangling=true\" --quiet | xargs -I {} docker rmi -f {}"
# Docker Compose
alias docker-compose="docker compose"
alias dcu="docker-compose up"
alias dcd="docker-compose down"
alias dcdro="docker-compose down --remove-orphans"
alias dck="docker-compose kill -s SIGKILL"
alias dcs="docker-compose stop"
alias dcb="docker-compose build"
alias dce="docker-compose exec"
alias dcl="docker-compose logs"
alias dcr="docker-compose run"
alias dct="docker-compose top"
alias dcud="docker-compose up -d"
alias dcbnc="docker-compose build --no-cache"
alias dcrmv="docker-compose rm -v -f"
####################
# EXPORTS
####################
# Default text editor
export EDITOR=vim
# Binaries
export PATH=$PATH:~/.my-binaries
# Terminal colors
export TERM=xterm-256color-italic
# Colors to ls
LS_COLORS='fi=0;92:rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=03;32:*.tar=2;37:*.tgz=2;37:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=2;37:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*.md=0;35:*.markdown=0;35:';
export LS_COLORS
# Vim/Nvim variables
export VIM_CUSTOM_MAX_COLUMN_LENGTH=121
###################
# FUNCTIONS
###################
function longls {
local HEADERS="SIZE|PERMS|LINK COUNT|OWNER|GROUP|SIZE|MOD TIME|NAME"
tput bold; tput smul; echo -e "$HEADERS" | column -t -s"|"; tput sgr0
if [ ! "${1}" ]; then
ls --color=always -ahlst | grep -v '^total'
else
ls --color=always -ahlst ${1} | grep -v '^total'
fi
}
function todayIs {
declare -a TEXTCOLORS=("1" "2" "3" "4" "5" "6" "7")
choosen=`shuf -i 1-${#TEXTCOLORS[@]} -n 1`
tput setaf ${TEXTCOLORS[$choosen]};tput bold; echo "Hoje é: "`date +%^A`, `date +%^B`, `date +%F`"\e[39m"
}
todayIs
function messageOfTheDay {
local MESSAGE_REQUEST=$(curl -s -X GET 'http://api.forismatic.com/api/1.0/?method=getQuote&format=json&lang=en')
if command -v jq &> /dev/null
then
echo -e "${MESSAGE_REQUEST}" | jq '.quoteText' | cowthink -f duck
else
echo -e "${MESSAGE_REQUEST}" | awk -F ':' '{print $2}' | sed 's/, "quoteAuthor"//g' | cowthink -f duck
fi
}
messageOfTheDay
function currentDir {
pwd | xclip
}
function goToDir {
cd $(xclip -o)
}
dotheupgrade() {
sudo apt update -y; sudo apt upgrade -y; sudo apt-get update -y; sudo apt autoremove -y; sudo apt autoclean -y
}
# Random phrases
function randomPhrase {
declare -a QUALITIES=("good" "bad" "great" "terrible" "nice" "tough")
declare -a SITUATIONS=("wear red socks on lava when using"
"fishing sharks using your enemies with"
"find a treasure hidden in your"
"read a book about psycopaths with"
"watch unicorns having sex using"
"learn how mummies use to cook people using"
"find an immigrant living inside your"
"drink a lot of coffee with"
"drive a racing car along with"
"open a can of beans using"
"wear anti-radiation clothes using your"
"see the sunrise at Chernobyl with"
"go to Mars using only your"
"leave your house with only your"
"travel to Spain riding"
"worship a God that looks like"
"create an statue of your"
"watch Rick and Morty with your"
"Get Schwifty using your"
"learn a new recipe on how to cook"
"fight aliens inside"
"watch a boring TV show along with your"
"choose your next president using"
"run naked with only your"
"eat boiling rice along with"
)
declare -a THINGS=("a cat"
"cat"
"a dog"
"dog"
"boots"
"hat"
"keyboard"
"bottle"
"money"
"a cactus"
"butter"
"bottle of Mountain Dew"
"spoon"
"fork"
"laser gun"
"corn"
"head"
"knife"
"Limp Bizkit album"
"Elvis costume"
"Terminator poster"
"Terminator"
"Barbie doll"
"poncho"
"credit card"
"bread"
"typewriter"
"machine gun"
"cocaine"
"bottle of 51"
"scissors"
"shark"
"chainsaw"
"Old Spice"
"TNT"
"cat"
"pencil"
"Apple Watch"
"cellphone"
"spear"
"Batman costume"
"can of beans"
"short camuflado da vovó Juju"
)
q=`shuf -i 1-${#QUALITIES[@]} -n 1`
s=`shuf -i 1-${#SITUATIONS[@]} -n 1`
t=`shuf -i 1-${#THINGS[@]} -n 1`
echo "Today is a ${QUALITIES[$q]} day to ${SITUATIONS[$s]} ${THINGS[$t]}." | cowsay -f skeleton
}
#randomPhrase
# TMUX / TMATE functions
TMATE_PAIR_NAME="$(whoami)-pair"
TMATE_SOCKET_LOCATION="/tmp/tmate-pair.sock"
TMATE_TMUX_SESSION="/tmp/tmate-tmux-session"
# Checks if there is a tmux session named 'dotfiles'
function checkDotfilesSession {
tmux ls | grep 'dotfiles' &> /dev/null
if [ $? = 0 ]; then
echo "TEM SIM"
return 1
else
echo "TEM NAO"
return 0
fi
}
#checkDotfilesSession
watchImages() {
watch -n 1 -t -c docker ps --format \"table {{.ID}}\\t{{.Image}}\\t{{.Ports}}\\t{{.State}}\\t{{.Status}}\\t{{.Names}}\\t{{.Networks}}\"
}
tmate-new() {
tmate -S $TMATE_SOCKET_LOCATION new -s "$1"
}
tmate-ls() {
tmate -S $TMATE_SOCKET_LOCATION ls
}
tmate-a() {
if [ -z $1 ]; then
tmate -S $TMATE_SOCKET_LOCATION a -t $TMATE_PAIR_NAME
else
tmate -S $TMATE_SOCKET_LOCATION a -t $1
fi
}
tmate-write-url() {
url="$(tmate -S $TMATE_SOCKET_LOCATION display -p 'WRITE: #{tmate_ssh} | #{tmate_web}')"
echo "$url" | tr -d '\n' | xclip
echo "Copied tmate URL for $TMATE_PAIR_NAME:"
echo "$url"
}
tmate-read-url() {
url="$(tmate -S $TMATE_SOCKET_LOCATION display -p 'READ: #{tmate_ssh_ro} | #{tmate_web_ro}')"
echo "$url" | tr -d '\n' | xclip
echo "Copied tmate URL for $TMATE_PAIR_NAME:"
echo "$url"
}
tmate-pair() {
if [ ! -e "$TMATE_SOCKET_LOCATION" ]; then
tmate -S "$TMATE_SOCKET_LOCATION" -f "$HOME/.tmate.conf" new-session -d -s "$TMATE_PAIR_NAME"
while [ -z "$url" ]; do
url="$(tmate -S $TMATE_SOCKET_LOCATION display -p '#{tmate_ssh}')"
done
tmate-write-url
sleep 1
if [ -n "$1" ]; then
echo $1 > $TMATE_TMUX_SESSION
tmate -S "$TMATE_SOCKET_LOCATION" send -t "$TMATE_PAIR_NAME" "TMUX='' tmux attach-session -t $1" ENTER
fi
fi
tmate -S "$TMATE_SOCKET_LOCATION" attach-session -t "$TMATE_PAIR_NAME"
}
tmate-unpair() {
if [ -e "$TMATE_SOCKET_LOCATION" ]; then
if [ -e "$TMATE_SOCKET_LOCATION" ]; then
tmux detach -s $(cat $TMATE_TMUX_SESSION)
rm -f $TMATE_TMUX_SESSION
fi
tmate -S "$TMATE_SOCKET_LOCATION" kill-session -t "$TMATE_PAIR_NAME"
echo "Killed session $TMATE_PAIR_NAME"
else
echo "Session already killed"
fi
}
function diffPR {
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ ! "${1}" ]; then
BRANCHES="$(git branch --remote | egrep '(main|master|develop)' | grep -v HEAD)"
echo $BRANCHES
echo Escolha uma das branches acima:
read BASE_BRANCH
else
BASE_BRANCH=${1}
fi
git difftool $BASE_BRANCH...$CUR_BRANCH --diff-filter=AM
}
function phpToolboxCBF {
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ ! "${1}" ]; then
BRANCHES="$(git branch --remote | egrep '(main|master|develop)' | grep -v HEAD)"
echo $BRANCHES
echo Escolha uma das branches acima:
read BASE_BRANCH
else
BASE_BRANCH=${1}
fi
git diff $BASE_BRANCH...$CUR_BRANCH --name-only --diff-filter=AM | grep '.php' | xargs -I {} sh -c 'printf "\nINSPECTING WITH PHPCBF %s:\n" {};docker run -t --rm -v $(pwd):/code -w /code devdrops/php-toolbox:latest phpcbf {}'
}
function phpToolboxCS {
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ ! "${1}" ]; then
BRANCHES="$(git branch --remote | egrep '(main|master|develop)' | grep -v HEAD)"
echo $BRANCHES
echo Escolha uma das branches acima:
read BASE_BRANCH
else
BASE_BRANCH=${1}
fi
git diff $BASE_BRANCH...$CUR_BRANCH --name-only --diff-filter=AM | grep '.php' | xargs -I {} sh -c 'printf "\nINSPECTING WITH PHPCS %s:\n" {};docker run -t --rm -v $(pwd):/code -w /code devdrops/php-toolbox:latest phpcs {}'
}
function phpToolboxCSFixer {
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ ! "${1}" ]; then
BRANCHES="$(git branch --remote | egrep '(main|master|develop)' | grep -v HEAD)"
echo $BRANCHES
echo Escolha uma das branches acima:
read BASE_BRANCH
else
BASE_BRANCH=${1}
fi
git diff $BASE_BRANCH...$CUR_BRANCH --name-only --diff-filter=AM | grep '.php' | xargs -I {} sh -c 'printf "\nINSPECTING WITH PHP CS FIXER %s:\n" {};docker run -t --rm -v $(pwd):/code -w /code devdrops/php-toolbox:latest php-cs-fixer fix {}'
}
function phpToolboxMD {
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ ! "${1}" ]; then
BRANCHES="$(git branch --remote | egrep '(main|master|develop)' | grep -v HEAD)"
echo $BRANCHES
echo Escolha uma das branches acima:
read BASE_BRANCH
else
BASE_BRANCH=${1}
fi
git diff $BASE_BRANCH...$CUR_BRANCH --name-only --diff-filter=AM | grep '.php' | xargs -I {} sh -c 'printf "\nINSPECTING WITH PHPMD %s:\n" {};docker run -t --rm -v $(pwd):/code -w /code devdrops/php-toolbox:latest phpmd {} text cleancode,codesize,controversial,design,naming,unusedcode'
}
function phpToolboxLoC {
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ ! "${1}" ]; then
BRANCHES="$(git branch --remote | egrep '(main|master|develop)' | grep -v HEAD)"
echo $BRANCHES
echo Escolha uma das branches acima:
read BASE_BRANCH
else
BASE_BRANCH=${1}
fi
git diff $BASE_BRANCH...$CUR_BRANCH --name-only --diff-filter=AM | grep '.php' | xargs -I {} sh -c 'printf "\nINSPECTING WITH PHPLOC %s:\n" {};docker run -t --rm -v $(pwd):/code -w /code devdrops/php-toolbox:latest phploc {}'
}
function phpToolboxStan {
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ ! "${1}" ]; then
BRANCHES="$(git branch --remote | egrep '(main|master|develop)' | grep -v HEAD)"
echo $BRANCHES
echo Escolha uma das branches acima:
read BASE_BRANCH
else
BASE_BRANCH=${1}
fi
git diff $BASE_BRANCH...$CUR_BRANCH --name-only --diff-filter=AM | grep '.php' | xargs -I {} sh -c 'printf "\nINSPECTING WITH PHPSTAN %s:\n" {};docker run -t --rm -v $(pwd):/code -w /code devdrops/php-toolbox:latest phpstan analyze {} --memory-limit 1G'
}
function phpToolboxPsalm {
CUR_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
if [ ! "${1}" ]; then
BRANCHES="$(git branch --remote | egrep '(main|master|develop)' | grep -v HEAD)"
echo $BRANCHES
echo Escolha uma das branches acima:
read BASE_BRANCH
else
BASE_BRANCH=${1}
fi
git diff $BASE_BRANCH...$CUR_BRANCH --name-only --diff-filter=AM | grep '.php' | xargs -I {} sh -c 'printf "\nINSPECTING WITH PSALM %s:\n" {};docker run -t --rm -v $(pwd):/code -w /code devdrops/php-toolbox:latest psalm {}'
}
function toB64 {
echo "${1}" | base64 -w 0 | xclip
}
function fromB64 {
echo ${1} | base64 -d | xclip
}
# Kubernetes
if command -v kubectl &> /dev/null
then
# setup autocomplete in zsh into the current shell
source <(kubectl completion zsh)
[[ $commands[kubectl] ]] && source <(kubectl completion zsh)
fi