Update ZSH prompt
Include a shortened version of the current directory.
This commit is contained in:
parent
7c507732f7
commit
46259edd2d
3 changed files with 28 additions and 2 deletions
|
@ -54,7 +54,8 @@
|
||||||
(environment-variables
|
(environment-variables
|
||||||
'(("HISTFILE" . "$HOME/.zsh/histfile")
|
'(("HISTFILE" . "$HOME/.zsh/histfile")
|
||||||
("HISTSIZE" . "1000")
|
("HISTSIZE" . "1000")
|
||||||
("SAVEHIST" . "1000")))
|
("SAVEHIST" . "1000")
|
||||||
|
("PROMPT" . "%T \\$(spwd) %B%(?.%F{2}.%F{1}[%?])>%b%f ")))
|
||||||
(zshrc
|
(zshrc
|
||||||
(list
|
(list
|
||||||
(mixed-text-file
|
(mixed-text-file
|
||||||
|
|
25
zsh/.zsh/functions/spwd
Normal file
25
zsh/.zsh/functions/spwd
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# From https://stackoverflow.com/a/45336078
|
||||||
|
paths=(${(s:/:)PWD})
|
||||||
|
|
||||||
|
cur_path='/'
|
||||||
|
cur_short_path='/'
|
||||||
|
for directory in ${paths[@]}
|
||||||
|
do
|
||||||
|
cur_dir=''
|
||||||
|
for (( i=0; i<${#directory}; i++ )); do
|
||||||
|
cur_dir+="${directory:$i:1}"
|
||||||
|
matching=("$cur_path"/"$cur_dir"*/)
|
||||||
|
if [[ ${#matching[@]} -eq 1 ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
cur_short_path+="$cur_dir/"
|
||||||
|
cur_path+="$directory/"
|
||||||
|
|
||||||
|
if [[ $cur_path == $HOME/ ]];
|
||||||
|
then cur_short_path='~/'
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
printf %b "${cur_short_path: : -1}"
|
||||||
|
echo
|
|
@ -207,6 +207,6 @@ Autoload any ZSH function from =$HOME/.zsh/functions=.
|
||||||
Set the actual prompts.
|
Set the actual prompts.
|
||||||
|
|
||||||
#+begin_src sh
|
#+begin_src sh
|
||||||
PROMPT='%T %2~ %B%(?.%F{2}.%F{1})→%b '
|
PROMPT='%T $(spwd) %B%(?.%F{2}.%F{1}[%?])>%b%f '
|
||||||
RPROMPT='${vcs_info_msg_0_}'
|
RPROMPT='${vcs_info_msg_0_}'
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
Loading…
Reference in a new issue