-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.common
122 lines (104 loc) · 2.52 KB
/
.common
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
#!/bin/bash
# This executes either from bashrc OR sshrc
# on both local and remote environments
# Let's support powerlife if we have it
powerline_init() {
powerline-daemon -q
export POWERLINE_BASH_CONTINUATION=1
export POWERLINE_BASH_SELECT=1
# shellcheck disable=SC1091
source /usr/share/powerline/bash/powerline.sh
}
is_powerline_session() {
hash powerline-daemon >/dev/null 2>&1
}
is_ledger_agent_session() {
local a ledger_virtual path_check
path_check=$(
a=$(command -v ledger-agent) \
&& [[ "$a" =~ alias ]] \
|| printf '%s' "$a"
)
ledger_virtual="$HOME/virtualenvs/ledger/bin/ledger-agent"
if [[ $path_check ]]; then
LEDGER_AGENT_BIN="$path_check"
elif [[ -x $ledger_virtual ]]; then
LEDGER_AGENT_BIN="$ledger_virtual"
fi
# shellcheck disable=SC2139
alias ledger-agent="$LEDGER_AGENT_BIN"
if [[ ${SSH_AUTH_SOCK,,} =~ (ledger|trezor) ]] \
|| ! lsusb -d 2c97: >/dev/null 2>&1; then
return 1
fi
return 0
}
is_libreoffice_session() {
hash libreoffice >/dev/null 2>&1
}
is_sshrc_session() {
[[ "$SSHHOME" ]]
}
is_ssh_session() {
[[ "$SSH_CONNECTION" && "$SSH_CLIENT" ]]
}
is_kubectl_session() {
hash kubectl >/dev/null 2>&1
}
is_x11_forward_session() {
[[ "$DISPLAY" =~ ^localhost ]]
}
is_terraform_session() {
hash terraform >/dev/null 2>&1
}
set_editor() {
EDITOR="$(type -P "$1")"
if [[ "$EDITOR" ]]; then
export EDITOR
export VISUAL="$EDITOR"
fi
if [[ "$EDITOR" =~ vim$ ]]; then
export MERGE="vimdiff"
fi
}
if is_powerline_session; then
__TMUXRC=".tmux.conf"
__VIMRC=".vimrc"
powerline_init
else
__TMUXRC=".tmux-nopl.conf"
__VIMRC=".vimrc"
fi
if is_ssh_session; then
if is_sshrc_session; then
# shellcheck disable=SC2086
eval export $SSHRC_D
export VIMINIT="let \$MYVIMRC='${SSHRC_D}/${__VIMRC}' | source \$MYVIMRC"
__TMUXRC="${SSHRC_D}/${__TMUXRC}"
else
export VIMINIT="let \$MYVIMRC='${HOME}/${__VIMRC}' | source \$MYVIMRC"
__TMUXRC="${HOME}/${__TMUXRC}"
fi
if is_x11_forward_session; then
export XDG_CURRENT_DESKTOP="kde"
fi
fi
if is_ledger_agent_session; then
"$LEDGER_AGENT_BIN" -se ed25519 -- [email protected]
fi
if [[ -d "$FIREFOX_DEV_PATH" ]]; then
export PATH="${PATH}:/opt/firefox-dev"
fi
if is_libreoffice_session; then
export SAL_USE_VCLPLUGIN=gtk
#export SAL_USE_VCLPLUGIN=kde
export VCL_ICONS_FOR_DARK_THEME=1
fi
if is_kubectl_session; then
[[ ! -f "$HOME/.kubectl_completion" ]] && kubectl completion bash > .kubectl_completion
# shellcheck disable=SC1090
source "$HOME/.kubectl_completion"
fi
if is_terraform_session; then
complete -C terraform terraform
fi