Skip to content

Commit

Permalink
Use Zsh field splitting instead of awk (spaceship-prompt#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
salmanulfarzy authored Nov 21, 2018
1 parent 898abaa commit b294f83
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion sections/docker.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ spaceship_docker() {
local docker_version=$(docker version -f "{{.Server.Version}}" 2>/dev/null)
[[ -z $docker_version ]] && return

[[ $SPACESHIP_DOCKER_VERBOSE == false ]] && docker_version=$(echo ${docker_version} | awk -F\- '{ print $1 }')
# Split output on separator (-) and return the first element from resulting array
[[ $SPACESHIP_DOCKER_VERBOSE == false ]] && docker_version=${${(@s|-|)docker_version}[1]}

if [[ -n $DOCKER_MACHINE_NAME ]]; then
docker_version+=" via ($DOCKER_MACHINE_NAME)"
Expand Down
3 changes: 2 additions & 1 deletion sections/ruby.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ spaceship_ruby() {
elif spaceship::exists rbenv; then
ruby_version=$(rbenv version-name)
elif spaceship::exists asdf; then
ruby_version=$(asdf current ruby | awk '{print $1}')
# split output on space and return first element
ruby_version=${$(asdf current ruby)[1]}
else
return
fi
Expand Down

0 comments on commit b294f83

Please sign in to comment.