-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_bashrc_nmandery
More file actions
109 lines (92 loc) · 3.5 KB
/
_bashrc_nmandery
File metadata and controls
109 lines (92 loc) · 3.5 KB
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
# vi mode command line editing (enter VI mode using ESC)
set -o vi
if type "__git_ps1" &>/dev/null; then
export GIT_PS1_SHOWDIRTYSTATE=1
# colored prompt
# the git branch depends on bash_completion which should be sourced before. on debian
# it is normally added to ~/.bashrc. Otherwise add
# if [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
# |------- user@host ------------| |----- directory -----------| |---- nonzero returncodes -------| |--------- git branch ----------------|
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;34m\]\w\[\033[00m\] \[\033[01;31m\]${?##0}\[\033[00m\] \[\033[00;33m\]$(__git_ps1)\[\033[00m\]\n\$ '
else
# |------- user@host ------------| |----- directory -----------| |---- nonzero returncodes -------|
export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]: \[\033[01;34m\]\w\[\033[00m\] \[\033[01;31m\]${?##0}\[\033[00m\]\n\$ '
fi
# disable visual bell. This setting should be placed in ~/.inputrc, calling bind with
# the setting as parameter will also work
bind 'set bell-style none'
# add go to path
if [ -d /opt/install/go ]; then
export GOROOT=/opt/install/go
export GOPATH=/opt/install/gopath
export PATH=$PATH:"$GOROOT/bin:$GOPATH/bin"
fi
# the default editor
if which vim >>/dev/null; then
export EDITOR=`which vim`
else
if which vi >>/dev/null; then
export EDITOR=`which vi`
fi
fi
export PSQL_EDITOR=$EDITOR
export SVN_EDITOR=$EDITOR
# fix java swing guis in awesomewm
# http://stackoverflow.com/questions/721215/how-can-i-fix-a-java-gui-program-swing-that-it-works-with-awesome-wm
# requires "wmname" from suckless
WMNAME=$(which wmname 2>/dev/null || echo "")
if [ "$WMNAME" != "" ]; then
$WMNAME LG3D
fi
function sleep_until() {
# http://stackoverflow.com/questions/645992/bash-sleep-until-a-specific-time-date
# examples:
# 'next week'
# '1 hour'
# '8:40'
_TSTAMP="$1"
sleep $(expr `date -d "$_TSTAMP" +%s` - `date -d 'now' +%s`)
}
# k8s when kubectl is in $PATH
if [[ $(type -P kubectl) ]]; then
alias k='sudo kubectl'
alias k-top='k get pods --all-namespaces -o wide'
function k-purge-finished-pods {
# delete finished pods
#
for phase in Failed Succeeded; do
echo "Purging pods with phase=$phase"
k delete pod --field-selector=status.phase==$phase --all-namespaces
done
}
function k-restart-deployment {
# restart-hack after https://medium.com/faun/how-to-restart-kubernetes-pod-7c702ca984c1
# to implement a restart by scaling down to 0 replicas and back up again
#
# usage example to restart traefik in k3s:
# k-restart-deployment -n kube-system traefik
#
local n_replicas=`k get deployment "$@" -o json | jq '.status.replicas'`
echo "Deployment was using replicas=$n_replicas, scaling down to 0"
k scale deployment "$@" --replicas=0
echo "Waiting a few seconds"
sleep 3
echo "Scaling back up to replicas=$n_replicas"
k scale deployment "$@" --replicas="$n_replicas"
}
fi
# include rustup environment when its installed
if [ -f "$HOME/.cargo/env" ]; then
. $HOME/.cargo/env
fi
alias ytop='echo "ytop has been superseed by btm (called bottom)'
if [ -d "$HOME/go" ]; then
export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$PATH"
fi
# include mcfly setup if its present. https://github.com/cantino/mcfly
if [ -x "$(which mcfly)" ]; then
eval "$(mcfly init bash)"
fi