Added a segment that shows the current GO version number.

This commit is contained in:
Dominik Ritter 2015-09-21 18:27:03 +02:00
parent 6cec4ce400
commit 1a5edebae7
2 changed files with 11 additions and 0 deletions

View file

@ -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.

View file

@ -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'