summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md7
-rw-r--r--functions/icons.zsh81
-rwxr-xr-xpowerlevel9k.zsh-theme43
-rwxr-xr-xtest/segments/kubecontext.spec38
4 files changed, 145 insertions, 24 deletions
diff --git a/README.md b/README.md
index 7c1974de..db514348 100644
--- a/README.md
+++ b/README.md
@@ -140,6 +140,7 @@ The segments that are currently available are:
* `aws_eb_env` - The current Elastic Beanstalk Environment.
* `docker_machine` - The current Docker Machine.
* `kubecontext` - The current context of your `kubectl` configuration.
+* `dropbox` - Indicates Dropbox directory and syncing status using `dropbox-cli`
**Other:**
* [`custom_command`](#custom_command) - Create a custom segment to display the
@@ -509,7 +510,11 @@ This segment shows the version of Ruby being used when using `rbenv` to change y
It figures out the version being used by taking the output of the `rbenv version-name` command.
* If `rbenv` is not in $PATH, nothing will be shown.
-* If the current Ruby version is the same as the global Ruby version, nothing will be shown.
+* By default, if the current local Ruby version is the same as the global Ruby version, nothing will be shown. See the configuration variable, below, to modify this behavior.
+
+Variable | Default Value | Description |
+|----------|---------------|-------------|
+|`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.|
##### rspec_stats
diff --git a/functions/icons.zsh b/functions/icons.zsh
index 7124386b..6ec07379 100644
--- a/functions/icons.zsh
+++ b/functions/icons.zsh
@@ -87,6 +87,7 @@ case $POWERLEVEL9K_MODE in
SSH_ICON '(ssh)'
VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈
+ DROPBOX_ICON $'\UF16B' # 
)
;;
'awesome-fontconfig')
@@ -158,6 +159,84 @@ case $POWERLEVEL9K_MODE in
SSH_ICON '(ssh)'
VPN_ICON $'\uF023'
KUBERNETES_ICON $'\U2388' # ⎈
+ DROPBOX_ICON $'\UF16B' # 
+ )
+ ;;
+ 'awesome-mapped-fontconfig')
+ # mapped fontconfig with awesome-font required! See
+ # https://github.com/gabrielelana/awesome-terminal-fonts
+ # don't forget to source the font maps in your startup script
+ # Set the right locale to protect special characters
+ local LC_ALL="" LC_CTYPE="en_US.UTF-8"
+
+ if [ -z "$AWESOME_GLYPHS_LOADED" ]; then
+ echo "Powerlevel9k warning: Awesome-Font mappings have not been loaded.
+ Source a font mapping in your shell config, per the Awesome-Font docs
+ (https://github.com/gabrielelana/awesome-terminal-fonts),
+ Or use a different Powerlevel9k font configuration.";
+ fi
+
+ icons=(
+ LEFT_SEGMENT_SEPARATOR $'\uE0B0' # 
+ RIGHT_SEGMENT_SEPARATOR $'\uE0B2' # 
+ LEFT_SEGMENT_END_SEPARATOR ' ' # Whitespace
+ LEFT_SUBSEGMENT_SEPARATOR $'\uE0B1' # 
+ RIGHT_SUBSEGMENT_SEPARATOR $'\uE0B3' # 
+ CARRIAGE_RETURN_ICON $'\u21B5' # ↵
+ ROOT_ICON '\u'$CODEPOINT_OF_OCTICONS_ZAP # 
+ RUBY_ICON '\u'$CODEPOINT_OF_OCTICONS_RUBY' ' # 
+ AWS_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER # 
+ AWS_EB_ICON $'\U1F331 ' # 🌱
+ BACKGROUND_JOBS_ICON '\u'$CODEPOINT_OF_AWESOME_COG' ' # 
+ TEST_ICON '\u'$CODEPOINT_OF_AWESOME_BUG # 
+ TODO_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK_SQUARE_O # 
+ BATTERY_ICON '\U'$CODEPOINT_OF_AWESOME_BATTERY_FULL # 
+ DISK_ICON '\u'$CODEPOINT_OF_AWESOME_HDD_O' ' # 
+ OK_ICON '\u'$CODEPOINT_OF_AWESOME_CHECK # 
+ FAIL_ICON '\u'$CODEPOINT_OF_AWESOME_TIMES # 
+ SYMFONY_ICON 'SF'
+ NODE_ICON $'\u2B22' # ⬢
+ MULTILINE_FIRST_PROMPT_PREFIX $'\u256D'$'\U2500' # ╭─
+ MULTILINE_SECOND_PROMPT_PREFIX $'\u2570'$'\U2500 ' # ╰─
+ APPLE_ICON '\u'$CODEPOINT_OF_AWESOME_APPLE # 
+ FREEBSD_ICON $'\U1F608 ' # 😈
+ LINUX_ICON '\u'$CODEPOINT_OF_AWESOME_LINUX # 
+ SUNOS_ICON '\u'$CODEPOINT_OF_AWESOME_SUN_O' ' # 
+ HOME_ICON '\u'$CODEPOINT_OF_AWESOME_HOME # 
+ HOME_SUB_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_OPEN # 
+ FOLDER_ICON '\u'$CODEPOINT_OF_AWESOME_FOLDER_O # 
+ NETWORK_ICON '\u'$CODEPOINT_OF_AWESOME_RSS # 
+ LOAD_ICON '\u'$CODEPOINT_OF_AWESOME_BAR_CHART' ' # 
+ SWAP_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD # 
+ RAM_ICON '\u'$CODEPOINT_OF_AWESOME_DASHBOARD # 
+ SERVER_ICON '\u'$CODEPOINT_OF_AWESOME_SERVER # 
+ VCS_UNTRACKED_ICON '\u'$CODEPOINT_OF_AWESOME_QUESTION_CIRCLE # 
+ VCS_UNSTAGED_ICON '\u'$CODEPOINT_OF_AWESOME_EXCLAMATION_CIRCLE # 
+ VCS_STAGED_ICON '\u'$CODEPOINT_OF_AWESOME_PLUS_CIRCLE # 
+ VCS_STASH_ICON '\u'$CODEPOINT_OF_AWESOME_INBOX' ' # 
+ VCS_INCOMING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_DOWN' ' # 
+ VCS_OUTGOING_CHANGES_ICON '\u'$CODEPOINT_OF_AWESOME_ARROW_CIRCLE_UP' ' # 
+ VCS_TAG_ICON '\u'$CODEPOINT_OF_AWESOME_TAG' ' # 
+ VCS_BOOKMARK_ICON '\u'$CODEPOINT_OF_OCTICONS_BOOKMARK # 
+ VCS_COMMIT_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_COMMIT' ' # 
+ VCS_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_GIT_BRANCH' ' # 
+ VCS_REMOTE_BRANCH_ICON '\u'$CODEPOINT_OF_OCTICONS_REPO_PUSH # 
+ VCS_GIT_ICON '\u'$CODEPOINT_OF_AWESOME_GIT' ' # 
+ VCS_GIT_GITHUB_ICON '\u'$CODEPOINT_OF_AWESOME_GITHUB_ALT' ' # 
+ VCS_GIT_BITBUCKET_ICON '\u'$CODEPOINT_OF_AWESOME_BITBUCKET' ' # 
+ VCS_GIT_GITLAB_ICON '\u'$CODEPOINT_OF_AWESOME_GITLAB' ' # 
+ VCS_HG_ICON '\u'$CODEPOINT_OF_AWESOME_FLASK' ' # 
+ VCS_SVN_ICON '(svn) '
+ RUST_ICON $'\uE6A8' # 
+ PYTHON_ICON $'\U1F40D' # 🐍
+ SWIFT_ICON $'\uE655' # 
+ PUBLIC_IP_ICON '\u'$CODEPOINT_OF_AWESOME_GLOBE # 
+ LOCK_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK # 
+ EXECUTION_TIME_ICON '\u'$CODEPOINT_OF_AWESOME_HOURGLASS_END # 
+ SSH_ICON '(ssh)'
+ VPN_ICON '\u'$CODEPOINT_OF_AWESOME_LOCK
+ KUBERNETES_ICON $'\U2388' # ⎈
+ DROPBOX_ICON '\u'$CODEPOINT_OF_AWESOME_DROPBOX # 
)
;;
'nerdfont-complete'|'nerdfont-fontconfig')
@@ -229,6 +308,7 @@ case $POWERLEVEL9K_MODE in
SSH_ICON $'\uF489' # 
VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈
+ DROPBOX_ICON $'\UF16B' # 
)
;;
*)
@@ -300,6 +380,7 @@ case $POWERLEVEL9K_MODE in
SSH_ICON '(ssh)'
VPN_ICON '(vpn)'
KUBERNETES_ICON $'\U2388' # ⎈
+ DROPBOX_ICON 'Dropbox'
)
;;
esac
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index f33d5a9a..a8293358 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -1063,17 +1063,17 @@ prompt_ram() {
}
# rbenv information
+set_default POWERLEVEL9K_RBENV_ALWAYS false
prompt_rbenv() {
if which rbenv 2>/dev/null >&2; then
local rbenv_version_name="$(rbenv version-name)"
local rbenv_global="$(rbenv global)"
- # Don't show anything if the current Ruby is the same as the global Ruby.
- if [[ $rbenv_version_name == $rbenv_global ]]; then
- return
+ # Don't show anything if the current Ruby is the same as the global Ruby
+ # unless `POWERLEVEL9K_RBENV_ALWAYS` is set.
+ if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then
+ "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
fi
-
- "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
fi
}
@@ -1150,7 +1150,7 @@ exit_code_or_status() {
else
local sig=$(( ec - 128 ))
local idx=$(( sig + 1 ))
- echo "${signals[$idx]}(-${sig})"
+ echo "SIG${signals[$idx]}(${sig})"
fi
}
@@ -1410,21 +1410,38 @@ prompt_dir_writable() {
fi
}
-# Kubernetes Current Context
+# Kubernetes Current Context/Namespace
prompt_kubecontext() {
local kubectl_version="$(kubectl version --client 2>/dev/null)"
if [[ -n "$kubectl_version" ]]; then
- # Get the current Kubernetes config context's namespaece
- local k8s_namespace=$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}')
# Get the current Kuberenetes context
- local k8s_context=$(kubectl config current-context)
+ local cur_ctx=$(kubectl config view -o=jsonpath='{.current-context}')
+ cur_namespace="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${cur_ctx}\")].context.namespace}")"
+ # If the namespace comes back empty set it default.
+ if [[ -z "${cur_namespace}" ]]; then
+ cur_namespace="default"
+ fi
- if [[ -z "$k8s_namespace" ]]; then
- k8s_namespace="default"
+ "$1_prompt_segment" "$0" "$2" "magenta" "white" "$cur_ctx/$cur_namespace" "KUBERNETES_ICON"
+ fi
+}
+
+# Dropbox status
+prompt_dropbox() {
+ # The first column is just the directory, so cut it
+ local dropbox_status="$(dropbox-cli filestatus . | cut -d\ -f2-)"
+
+ # Only show if the folder is tracked and dropbox is running
+ if [[ "$dropbox_status" != 'unwatched' && "$dropbox_status" != "isn't running!" ]]; then
+ # If "up to date", only show the icon
+ if [[ "$dropbox_status" =~ 'up to date' ]]; then
+ dropbox_status=""
fi
- "$1_prompt_segment" "$0" "$2" "magenta" "white" "$k8s_context/$k8s_namespace" "KUBERNETES_ICON"
+
+ "$1_prompt_segment" "$0" "$2" "white" "blue" "$dropbox_status" "DROPBOX_ICON"
fi
+
}
diff --git a/test/segments/kubecontext.spec b/test/segments/kubecontext.spec
index eaaa2300..4f1d2c5e 100755
--- a/test/segments/kubecontext.spec
+++ b/test/segments/kubecontext.spec
@@ -18,11 +18,19 @@ function mockKubectl() {
;;
'config')
case "$2" in
- 'current-context')
- echo 'minikube'
- ;;
- 'get-contexts')
- echo '* minikube minikube minikube '
+ 'view')
+ case "$3" in
+ '-o=jsonpath={.current-context}')
+ echo 'minikube'
+ ;;
+ '-o=jsonpath={.contexts'*)
+ echo ''
+ ;;
+ *)
+ echo "Mock value missed"
+ exit 1
+ ;;
+ esac
;;
esac
;;
@@ -36,11 +44,21 @@ function mockKubectlOtherNamespace() {
;;
'config')
case "$2" in
- 'current-context')
- echo 'minikube'
- ;;
- 'get-contexts')
- echo '* minikube minikube minikube kube-system'
+ 'view')
+ case "$3" in
+ # Get Current Context
+ '-o=jsonpath={.current-context}')
+ echo 'minikube'
+ ;;
+ # Get current namespace
+ '-o=jsonpath={.contexts'*)
+ echo 'kube-system'
+ ;;
+ *)
+ echo "Mock value missed"
+ exit 1
+ ;;
+ esac
;;
esac
;;