From 1a5edebae76586361258ab68cb3f26148dfe026e Mon Sep 17 00:00:00 2001 From: Dominik Ritter Date: Mon, 21 Sep 2015 18:27:03 +0200 Subject: [PATCH] Added a segment that shows the current GO version number. --- README.md | 1 + powerlevel9k.zsh-theme | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/README.md b/README.md index 98033e79..6dfd7240 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,7 @@ currently available are: * **context** - Your username and host (more info below) * **vi_mode** - Vi editing mode (NORMAL|INSERT). * **dir** - Your current working directory. +* **go_version** - Show the current GO version. * **history** - The command number for the current line. * **ip** - Shows the current IP address. * **load** - Your machines 5 minute load average and free RAM. diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index 86fc2c42..413a61f5 100644 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -608,6 +608,16 @@ prompt_dir() { "$1_prompt_segment" "$0" "blue" "$DEFAULT_COLOR" "$(print_icon 'HOME_ICON')$current_path" } +# GO-prompt +prompt_go_version() { + local go_version + go_version=$(go version 2>&1 | grep -oe "^go[0-9.]*") + + if [[ -n "$go_version" ]]; then + "$1_prompt_segment" "$0" "green" "255" "$go_version" + fi +} + # Command number (in local history) prompt_history() { "$1_prompt_segment" "$0" "244" "$DEFAULT_COLOR" '%h'