-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt
More file actions
29 lines (22 loc) · 866 Bytes
/
prompt
File metadata and controls
29 lines (22 loc) · 866 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env bash
export GIT_PS1_STATESEPARATOR=":"
export GIT_PS1_SHOWDIRTYSTATE=1
export GIT_PS1_SHOWSTASHSTATE=1
export GIT_PS1_SHOWUNTRACKEDFILES=1
export PROMPT_COMMAND="_prompt_command"
_prompt_command() {
# Save the status before anything else so $? does not get overwritten.
local EXIT=$?
local _status _pwd
local _hl="\[\e[100;97m\]" # dark gray background white foreground
local _reset="\[\e[0m\]" # reset all attributes
if [ "$EXIT" != 0 ]; then
_status="$EXIT "
fi
local proj=${PROJECT_PROMPT:-''}
_pwd=$(pwd | awk -F/ 'NF <= 3 { printf "%s", $0 } NF > 3 { printf "%s/%s", $(NF-1), $NF }')
__git_ps1 "${_status}${proj}" "${_pwd} $ " "%s "
history -a # Append new lines to history file
history -c # Clear the history list
history -r # Append the history file to the history list
}