forked from bbcelly/git_prompt_and_bashrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashrc_tweaks
105 lines (90 loc) · 2.72 KB
/
bashrc_tweaks
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
###
### Sharing history between console windows
###
# Avoid duplicates
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# After each command, append to the history file and reread it
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
###
### End of sharing history
###
# https://krew.sigs.k8s.io/docs/user-guide/setup/install/
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
# https://github.com/bigH/git-fuzzy
export PATH="/w/tools/git-fuzzy/bin:$PATH"
source <(kubectl completion bash)
###
### Autocomplete for servers
### https://wiki.livesport.eu/wiki/LAK_-_LDAP_a_Kerberos/
###
alias lskinit='op --account "livesport.1password.eu" read "op://Private/LDAP/password" | /usr/bin/kinit -r 7d jiri.cerny'
ssh_func () {
local domain="$1"
local server="$2"
if klist -s; then
ssh -l jiri.cerny "$server.$domain"
else
if klist 2>&1 | grep -q 'krbtgt/[email protected]'; then
echo "TGT expired."
else
echo "TGT is not obtained."
fi
lskinit
if klist -s; then
ssh -l jiri.cerny "$server.$domain"
else
echo "TGT wasn't obtain."
fi
fi
}
ssa () {
ssh_func srv.lsoffice.cz "$1"
}
sss () {
ssh_func ls.intra "$1"
}
sst () {
ssh_func tt2.lssrv.tech "$1"
}
# ls.intra completion
_ssh_servers()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
local servers=$(dig -4 ls.intra axfr @ns.lsoffice.cz | grep "ls.intra" | awk '{ sub(/\.ls\.intra\.$/,"",$1) ; print $1 }')
COMPREPLY=($(compgen -W "${servers}" -- ${cur}))
return 0
}
complete -F _ssh_servers sss
# srv.lsoffice.cz completion
_ssha_servers()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
local servers=$(dig -4 srv.lsoffice.cz axfr @ns.lsoffice.cz | grep "srv.lsoffice.cz" | grep -v "^*" | awk '{ sub(/\.srv\.lsoffice\.cz\.$/,"",$1) ; print $1 }')
COMPREPLY=($(compgen -W "${servers}" -- ${cur}))
return 0
}
complete -F _ssha_servers ssa
# lssrv.tech completion
_ssh_tt2_servers()
{
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
local servers=$(dig -4 tt2.lssrv.tech axfr @ns.lsoffice.cz | grep "tt2.lssrv.tech" | awk '{ sub(/\.tt2\.lssrv\.tech\.$/,"",$1) ; print $1 }')
###local servers=$(dig -4 tt2.lssrv.tech axfr @ns.lsoffice.cz | grep "tt2.lssrv.tech" )
COMPREPLY=($(compgen -W "${servers}" -- ${cur}))
return 0
}
complete -F _ssh_tt2_servers sst