Last active
December 11, 2015 21:58
-
-
Save nickludlam/4666172 to your computer and use it in GitHub Desktop.
A section of my .profile which puts the running VM count into the prompt.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parse_vagrant_vms { | |
# Use sed to strip out the whitespace, can't seem to get wc to give nice formatting standalone | |
# Thanks to @pkqk for showing me the speedy 'VBoxManage' command | |
local vm_count=$(VBoxManage list runningvms | wc -l | sed 's/^ *//; s/; */;/g') | |
# I use curly braces to mean vm count, edit to taste | |
if [ $vm_count -eq 1 ]; then | |
echo "{${vm_count}vm}" | |
fi | |
if [ $vm_count -gt 1 ]; then | |
echo "{${vm_count}vms}" | |
fi | |
} | |
# In my true profile, there's a lot more in PS1 than this, but I've edited for brevity | |
export PS1="\$(parse_vagrant_vms)\n\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment