Last active
July 4, 2016 16:23
-
-
Save kamataryo/9ffd349ef806d5cdbc6b48949a853b63 to your computer and use it in GitHub Desktop.
bash/zsh prompt support to check if Vagrantfile exists.
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
# Add or custome for your .bashrc | |
source ~/.vagrant-prompt.sh | |
export PS1='\u@\h \W\[\033[33m\]$(__vagrant_pt)\[\033[00m\] $ ' |
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
#!/bin/sh | |
# bash/szh vagrant prompt support | |
__vagrant_pt(){ | |
dirname=$(pwd) | |
# prevent to trap while, when you are on not-existing dir | |
if [[ ! -d $dirname ]]; then | |
return | |
fi | |
if [[ -e "$dirname/Vagrantfile" ]]; then | |
echo "[vm]" | |
else | |
while [ "$dirname" != "/" ] | |
do | |
dirname=$(cd $dirname/..;pwd) | |
if [[ -e $dirname/Vagrantfile ]]; then | |
echo "[>vm]" | |
break | |
fi | |
done | |
fi | |
} |
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
# Add or custome for your .zshrc | |
setopt PROMPT_SUBST | |
source ~/.vagrant-prompt.sh | |
export PS1='%n@%m %c%F{yellow}$(__vagrant_pt)%f \$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment