The Bash shell prompt in your Terminal is very highly customizable and can display a wide variety of useful information. This is what my prompt looks like and how to create it.
The following information is presented at the prompt:
[09:10:11] : the current time
[email protected] : the name of the logged in user and the host machine
~/Desktop : the current working directory
+ or
-_- : this part presents the exit status of the most recently executed command. If the command executes correctly the prompt shows a green +. If the command returns an error, then the prompt shows an unhappy -_-.
Bash version
In order to recreate this prompt, you should add the following code to your ~/.bash_profile file. On some systems this file may need to be created, or you’ll need to edit the ~/.bashrc file instead.
function fish_prompt --description 'Write out the prompt'#Save the return status of the previous commandset stat $status# Just calculate these once, to save a few cycles when displaying the promptif not set -q __fish_prompt_hostname
set -g __fish_prompt_hostname (hostname|cut -d . -f 1) end
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal) end
if not set -q __fish_color_blue
set -g __fish_color_blue (set_color -o blue) end
#Set the color for the status depending on the valueset __fish_color_status (set_color -o green)if test$stat -gt 0
set __fish_color_status (set_color -o red) end
switch $USERcase root
if not set -q __fish_prompt_cwd
if set -q fish_color_cwd_root
set -g __fish_prompt_cwd (set_color $fish_color_cwd_root)elseset -g __fish_prompt_cwd (set_color $fish_color_cwd) end
end
printf'%[email protected]%s %s%s%s# '$USER$__fish_prompt_hostname"$__fish_prompt_cwd"(prompt_pwd)"$__fish_prompt_normal"case'*'if not set -q __fish_prompt_cwd
set -g __fish_prompt_cwd (set_color $fish_color_cwd) end
printf'[%s] %s%[email protected]%s %s%s %s(%s)%s \f\r> '(date "+%H:%M:%S")"$__fish_color_blue"$USER$__fish_prompt_hostname"$__fish_prompt_cwd"(pwd)"$__fish_color_status""$stat""$__fish_prompt_normal" end
end