-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.iterm2
51 lines (41 loc) · 1.43 KB
/
.iterm2
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
#!/usr/bin/env bash
# https://www.nicksays.co.uk/iterm-tool-versions-status-bar/
# sourced in powerline bash prompt
# inlined these iterm2 functions from the iterm shell integrations collection
# hardcoded begin_osc (\033) and end_osc (\007) values bc the existing
# implementation wouldn't escape properly
# https://iterm2.com/documentation-shell-integration.html
# set window title
title (){
echo -ne "\033]0;$*\007"
}
# set cursor color
# https://groups.google.com/g/iterm2-discuss/c/z-kH3NgBzTU/m/1TDni-sF8NcJ
# make the cursor light blue (rgb 4040ff):
# echo -e "\033]Pl4040ff\033\\"
__kube_context(){
! command -v kubectl >/dev/null 2>&1 && return # kubectl not installed
context=$(kubectl config current-context 2>&1)
if [[ "$context" == 'error: current-context is not set' ]]; then
return
elif [[ "$context" == 'docker-desktop' ]]; then
return
else
echo "$context"
fi
}
__iterm2_status_info() {
declare -A arr
arr[kubectlContext]="$(__kube_context)"
arr[terraformVersion]="$(tfenv version-name 2> /dev/null)"
arr[rubyVersion]="$(rbenv version-name 2> /dev/null)"
arr[awsProfile]="${AWS_PROFILE}"
__iterm2_set_user_var () {
printf "\033]1337;SetUserVar=%s=%s\007" "$1" "$(printf "%s" "$2" | base64 | tr -d '\n')"
}
for i in "${!arr[@]}"; do
__iterm2_set_user_var "${i}" "${arr[${i}]}"
done
# iTerm says this has to return true and produce no other output but that slows it down
# true
}