Difference between revisions of "Bash"
From John Freier
Line 12: | Line 12: | ||
echo "var is not set" | echo "var is not set" | ||
fi | fi | ||
+ | |||
+ | |||
+ | == Change the command prompt. == | ||
+ | To change the command prompt, export the below value. | ||
+ | export PS1=">" | ||
+ | or | ||
+ | export PS1="${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)" |
Revision as of 14:37, 17 May 2022
One line conditional
Both the following lines will write to the screen "false"
[[ 1 == 0 ]] || echo "text"
[[ 1 == 1 ]] && echo "text"
Check for environment variable
This will check to see if an variable is set
if [[ -z "$var" ]]; then echo "var is not set" fi
Change the command prompt.
To change the command prompt, export the below value.
export PS1=">"
or
export PS1="${ret_status} %{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)"