mirror of https://github.com/bjeanes/dotfiles.git
Switch ZSH prompt to P10K
parent
f1a146d9b4
commit
f2bc9fe158
8
freshrc
8
freshrc
|
@ -45,6 +45,8 @@ fresh-options --file=~/.vimrc --marker='"'
|
|||
fresh-options
|
||||
|
||||
fresh-options --file=~/.zshrc --marker
|
||||
fresh shells/zsh/p10k-instant-prompt.zsh
|
||||
|
||||
fresh shells/path.sh
|
||||
|
||||
fresh freshshell/fresh contrib/source-build.sh
|
||||
|
@ -56,8 +58,10 @@ fresh-options --file=~/.zshrc --marker
|
|||
fresh junegunn/fzf shell/key-bindings.zsh
|
||||
|
||||
fresh shells/common/\*.sh
|
||||
fresh shells/zsh/\*.zsh
|
||||
fresh shells/zsh/lib/\*.zsh
|
||||
|
||||
fresh shells/zsh/p10k.zsh
|
||||
|
||||
fresh shells/local.zsh
|
||||
fresh-options
|
||||
|
||||
|
@ -74,6 +78,8 @@ fresh freshshell/fresh contrib/completion/fresh-completion.zsh --file=completion
|
|||
fresh thoughtbot/dotfiles zsh/completion/_ag --file=completion/_ag
|
||||
fresh shells/zsh/completions --file=completion/
|
||||
|
||||
fresh romkatv/powerlevel10k . --file=vendor/powerlevel10k/
|
||||
|
||||
fresh zdharma/fast-syntax-highlighting . --file=vendor/zsh-fast-syntax-highlighting/
|
||||
fresh zsh-users/zsh-history-substring-search . --file=vendor/zsh-history-substring-search/
|
||||
fresh zsh-users/zsh-autosuggestions . --file=vendor/zsh-autosuggestions/
|
||||
|
|
|
@ -1,125 +1 @@
|
|||
pr_reset="%f%u%k%s%b" # reset all codes
|
||||
|
||||
pr_red="%F{red}"
|
||||
pr_blue="%F{blue}"
|
||||
pr_green="%F{green}"
|
||||
pr_grey="%B%F{black}"
|
||||
|
||||
if [ "$(tput colors 2>/dev/null)" -eq 256 ]; then
|
||||
pr_red="%F{52}"
|
||||
pr_blue="%F{33}"
|
||||
pr_green="%F{28}"
|
||||
pr_grey="%F{59}"
|
||||
fi
|
||||
|
||||
# VCS configuration
|
||||
autoload vcs_info
|
||||
zstyle ':vcs_info:*' enable git hg svn
|
||||
zstyle ':vcs_info:*' get-revision true
|
||||
zstyle ':vcs_info:*' formats "(%s) %b@%6>>%i%<<…" "%r" "%R" "%S"
|
||||
zstyle ':vcs_info:*' actionformats "(%s) %b@%6>>%i%<<…|%U%a%%u"
|
||||
zstyle ':vcs_info:*' branchformat "%b:%r"
|
||||
zstyle ':vcs_info:hg*:*' use-simple true
|
||||
zstyle ':vcs_info:svn:*' formats "(%s) %b:r%i" "%r"
|
||||
zstyle ':vcs_info:svn:*' branchformat "%b"
|
||||
|
||||
# TODO:
|
||||
# - Discover root of repo based on full path, not basename (to avoid underlining multiple path components) ($vcs_info_msg_2_)
|
||||
function prompt_pwd() {
|
||||
local repo="$vcs_info_msg_1_"
|
||||
|
||||
parts=(${(s:/:)${${PWD}/#${HOME}/\~}})
|
||||
|
||||
i=0
|
||||
while (( i++ < ${#parts} )); do
|
||||
part="$parts[i]"
|
||||
if [[ "$part" == "$repo" ]]; then
|
||||
# if this part of the path represents the repo,
|
||||
# underline it, and skip truncating the component
|
||||
parts[i]="%U$part%u"
|
||||
else
|
||||
# Shorten the path as long as it isn't the last piece
|
||||
if [[ "$parts[${#parts}]" != "$part" ]]; then
|
||||
parts[i]="$part[1,1]"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
local prompt_path="${(j:/:)parts}"
|
||||
if [ "$parts[1]" != "~" ]; then
|
||||
prompt_path="/$prompt_path"
|
||||
fi
|
||||
echo "$prompt_path"
|
||||
}
|
||||
|
||||
|
||||
function prompt_pwd_new() {
|
||||
local parts path part cwd i=0
|
||||
typeset -L path
|
||||
|
||||
|
||||
parts=(${(s:/:)${${PWD}/#${HOME}/\~}})
|
||||
|
||||
while (( i++ < ${#parts} )); do
|
||||
part="$parts[i]"
|
||||
|
||||
if [[ "$part" == "~" ]]; then
|
||||
path="$part"
|
||||
else
|
||||
# This check is broken because LHS is collapsed, RHS is expanded
|
||||
if [[ "$path/$part" == "${vcs_info_msg_2_/#${HOME}/~}" ]]; then
|
||||
part="%U$part%u"
|
||||
elif [[ "$parts[${#parts}]" != "$part" ]]; then
|
||||
part="$part[1,1]"
|
||||
fi
|
||||
|
||||
path="$path/$part"
|
||||
fi
|
||||
|
||||
# if [[ "$part" == "$repo" ]]; then
|
||||
# # if this part of the path represents the repo,
|
||||
# # underline it, and skip truncating the component
|
||||
# parts[i]="%U$part%u"
|
||||
# else
|
||||
# # Shorten the path as long as it isn't the last piece
|
||||
# if [[ "$parts[${#parts}]" != "$part" ]]; then
|
||||
# parts[i]="$part[1,1]"
|
||||
# fi
|
||||
# fi
|
||||
done
|
||||
|
||||
echo "$path"
|
||||
}
|
||||
|
||||
function default_precmd {
|
||||
if [ -z $INSIDE_EMACS ]; then
|
||||
vcs_info
|
||||
|
||||
local cwd="$pr_blue`prompt_pwd`$pr_reset"
|
||||
local char="%0(?.$pr_green.$pr_red)♪$pr_reset"
|
||||
# local time="$pr_grey⌚ %*$pr_reset"
|
||||
|
||||
local ruby
|
||||
ruby="$(current_ruby)"
|
||||
[ "x$ruby" != "x" ] && ruby="❖ $ruby"
|
||||
|
||||
local rev="$pr_grey$vcs_info_msg_0_$pr_reset"
|
||||
rev="${rev/\(git\)/±}"
|
||||
rev="${rev/\(hg\)/☿}"
|
||||
rev="${rev/\(svn\)/↯}"
|
||||
|
||||
local left right
|
||||
left=($(user_at_host) $cwd)
|
||||
right=($rev $ruby $time)
|
||||
|
||||
PS1=$left$'\n'$char' '
|
||||
RPS1="%{$(echotc UP 1)%}$right%{$(echotc DO 1)%}"
|
||||
else
|
||||
PS1="$ "
|
||||
RPS1=""
|
||||
fi
|
||||
}
|
||||
|
||||
function precmd {
|
||||
default_precmd
|
||||
}
|
||||
source $FRESH_PATH/build/vendor/powerlevel10k/powerlevel10k.zsh-theme
|
|
@ -0,0 +1,6 @@
|
|||
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
|
||||
# Initialization code that may require console input (password prompts, [y/n]
|
||||
# confirmations, etc.) must go above this block; everything else may go below.
|
||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||
fi
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue