diff --git a/base/bashrc b/base/bashrc index 492fab0..aeb2b3c 100644 --- a/base/bashrc +++ b/base/bashrc @@ -18,31 +18,6 @@ x-have antidot && { eval "$(antidot init)" } -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi - -if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - # We have color support; assume it's compliant with Ecma-48 - # (ISO/IEC-6429). (Lack of such support is extremely rare, and such - # a case would tend to support setf rather than setaf.) - color_prompt=yes -else - color_prompt= -fi - -if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[01;33m\]@\[\033[01;36m\]\h \[\033[01;33m\]\w \[\033[01;35m\]\$ \[\033[00m\]' -else - PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' -fi -unset color_prompt - -# If this is an xterm set the title to user@host:dir -case "$TERM" in -xterm* | rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" - ;; -*) ;; -esac +PROMPT_DIRTRIM=3 +PROMPT_COMMAND='PS1_CMD1=$(git branch --show-current 2>/dev/null)' +PS1='\[\e[95m\]\u\[\e[0m\]@\[\e[38;5;22;2m\]\h\[\e[0m\] \[\e[38;5;33m\]\w\[\e[0m\] \[\e[92;2m\]${PS1_CMD1}\n\[\e[39m\]➜\[\e[0m\] ' diff --git a/base/zshrc b/base/zshrc index 81a5732..4e1ca27 100644 --- a/base/zshrc +++ b/base/zshrc @@ -4,6 +4,7 @@ # export VERBOSE=1 # export DEBUG=1 +autoload -U promptinit; promptinit export DOTFILES="$HOME/.dotfiles" LOCAL_SHARE="$HOME/.local/share" @@ -15,75 +16,8 @@ source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc" ZSH_COMPDUMP="$XDG_CACHE_HOME/zsh/zcompdump-${SHORT_HOST}-${ZSH_VERSION}" -# Setup prompt -autoload -Uz vcs_info -zstyle ':vcs_info:*' check-for-changes true -zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes -zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes -zstyle ':vcs_info:*' actionformats '%F{5}%F{2}%b%F{3}|%F{1}%a%c%u%F{5}%f ' -zstyle ':vcs_info:*' formats '%F{5}%F{2}%b%c%u%F{5}%f ' -zstyle ':vcs_info:*' enable git cvs svn - -ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}" -ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" -ZSH_THEME_GIT_PROMPT_DIRTY="" -ZSH_THEME_GIT_PROMPT_CLEAN="" - -ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}✚" -ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[yellow]%}✹" -ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}✖" -ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%}➜" -ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%}═" -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%}✭" - -theme_precmd () { - vcs_info -} - -setopt PROMPT_SUBST -NEWLINE=$'\n' -PROMPT='%F{green}%m%f %F{blue}%~%f %{$reset_color%}${vcs_info_msg_0_}$(git_prompt_status)%{$reset_color%}${NEWLINE}➜ ' - -autoload -U add-zsh-hook -add-zsh-hook precmd theme_precmd - -# Setup antidote -load_antidote() -{ - [[ ! -d "$ANTIDOTE_DIR" ]] && { - git submodule add \ - --name antidote \ - --depth=1 \ - -f https://github.com/mattmc3/antidote.git "${ANTIDOTE_DIR}" - git config -f .gitmodules submodule.antidote.shallow true - } - - # Plugin configurations - zstyle ':antidote:bundle' use-friendly-names 'yes' - zstyle ':omz:update' mode reminder - zstyle ':omz:plugins:nvm' autoload yes - - # Disable ls colors to avoid issues with eza - export DISABLE_LS_COLORS=true - zstyle ':omz:plugins:eza' 'dirs-first' yes - zstyle ':omz:plugins:eza' 'git-status' yes - zstyle ':omz:plugins:eza' 'icons' yes - zstyle ':omz:plugins:eza' 'ls' yes - zstyle ':omz:plugins:eza' 'prompt' yes - - zsh_plugins=${ANTIDOTE_PLUGINS} - [[ -f ${zsh_plugins}.txt ]] || touch ${zsh_plugins}.txt - # Lazy-load antidote from its functions directory. - FPATH="$ANTIDOTE_DIR/functions:$FPATH" - autoload -Uz antidote - # Generate a new static file whenever .zsh_plugins.txt is updated. - if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then - antidote bundle <${zsh_plugins}.txt >|${zsh_plugins}.zsh - fi - - # Source your static plugins file. - source ${zsh_plugins}.zsh -} +source "$DOTFILES/config/zsh/antidote.zsh" +# source "$DOTFILES/config/zsh/prompt.zsh" # Function to source FZF configuration source_fzf_config() @@ -111,7 +45,6 @@ setup_tmux_window_name_plugin() fi } -load_antidote source_fzf_config setup_tmux_window_name_plugin x-have antidot && eval "$(antidot init)" diff --git a/config/zsh/antidote.zsh b/config/zsh/antidote.zsh new file mode 100755 index 0000000..a8af601 --- /dev/null +++ b/config/zsh/antidote.zsh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Setup antidote for Oh My Zsh +# vim: ft=zsh et sw=2 ts=2 + +[[ -z "$DOTFILES" ]] && DOTFILES="$HOME/.dotfiles" +[[ -z "$ANTIDOTE_DIR" ]] && ANTIDOTE_DIR="$DOTFILES/tools/antidote" +[[ -z "$ANTIDOTE_HOME" ]] && ANTIDOTE_HOME="$XDG_CACHE_HOME/antidote" +[[ -z "$ANTIDOTE_PLUGINS" ]] && ANTIDOTE_PLUGINS="$XDG_CONFIG_HOME/zsh/antidote_plugins" + +[[ ! -d "$ANTIDOTE_DIR" ]] && { + git submodule add \ + --name antidote \ + --depth=1 \ + -f https://github.com/mattmc3/antidote.git "${ANTIDOTE_DIR}" + git config -f .gitmodules submodule.antidote.shallow true +} + +# Plugin configurations +zstyle ':antidote:bundle' use-friendly-names 'yes' +zstyle ':omz:update' mode reminder +zstyle ':omz:plugins:nvm' autoload yes + +# Pure prompt settings +export PURE_PROMPT_SYMBOL='➜' +export PURE_GIT_UNTRACKED_DIRTY=0 +zstyle ':prompt:pure:git:stash' show yes +zstyle ':prompt:pure:path' color white +zstyle ':prompt:pure:prompt:success' color green +zstyle ':prompt:pure:prompt:error' color red + +# Disable ls colors to avoid issues with eza +export DISABLE_LS_COLORS=true +zstyle ':omz:plugins:eza' 'dirs-first' yes +zstyle ':omz:plugins:eza' 'git-status' yes +zstyle ':omz:plugins:eza' 'icons' yes +zstyle ':omz:plugins:eza' 'ls' yes +zstyle ':omz:plugins:eza' 'prompt' yes + +[[ -f "${ANTIDOTE_PLUGINS}.txt" ]] || touch "${ANTIDOTE_PLUGINS}.txt" +FPATH="$ANTIDOTE_DIR/functions:$FPATH" +autoload -Uz antidote +if [[ ! "${ANTIDOTE_PLUGINS}.zsh" -nt "${ANTIDOTE_PLUGINS}.txt" ]]; then + antidote bundle <"${ANTIDOTE_PLUGINS}.txt" >|"${ANTIDOTE_PLUGINS}.zsh" +fi + +# Source your static plugins file. +# shellcheck source=$HOME/.dotfiles/config/zsh/antidote_plugins.zsh +source "${ANTIDOTE_PLUGINS}.zsh" diff --git a/config/zsh/antidote_plugins.txt b/config/zsh/antidote_plugins.txt index d1b20d2..73a4fa5 100644 --- a/config/zsh/antidote_plugins.txt +++ b/config/zsh/antidote_plugins.txt @@ -10,6 +10,10 @@ zsh-users/zsh-completions kind:fpath path:src getantidote/use-omz # handle OMZ dependencies ohmyzsh/ohmyzsh path:lib # load OMZ's library +# Use pure prompt +mafredri/zsh-async +sindresorhus/pure + ohmyzsh/ohmyzsh path:plugins/colored-man-pages ohmyzsh/ohmyzsh path:plugins/brew ohmyzsh/ohmyzsh path:plugins/extract @@ -20,7 +24,6 @@ ohmyzsh/ohmyzsh path:plugins/golang ohmyzsh/ohmyzsh path:plugins/gpg-agent ohmyzsh/ohmyzsh path:plugins/nvm ohmyzsh/ohmyzsh path:plugins/python -# ohmyzsh/ohmyzsh path:plugins/ssh-agent ohmyzsh/ohmyzsh path:plugins/tmux ohmyzsh/ohmyzsh path:plugins/z @@ -35,4 +38,4 @@ jreese/zsh-titles yuki-ycino/tms # This needs to be last bundle -zsh-users/zsh-syntax-highlighting +# zsh-users/zsh-syntax-highlighting diff --git a/config/zsh/prompt.zsh b/config/zsh/prompt.zsh new file mode 100755 index 0000000..7da7f9c --- /dev/null +++ b/config/zsh/prompt.zsh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# Setup prompt +# vim: ft=zsh: + +setopt PROMPT_SUBST + +# Setup vcs_info +autoload -Uz vcs_info +zstyle ':vcs_info:*' enable git +zstyle ':vcs_info:*' max-exports 2 +zstyle ':vcs_info:*' check-for-changes true +zstyle ':vcs_info:*' check-for-staged-changes true +zstyle ':vcs_info:*' use-simple true +zstyle ':vcs_info:*' unstagedstr '%F{red}*' # display this when there are unstaged changes +zstyle ':vcs_info:*' stagedstr '%F{yellow}+' # display this when there are staged changes + +zstyle ':vcs_info:*' formats '%F{5}%F{2}%b%c%u%F{5}%f ' +zstyle ':vcs_info:*' actionformats '%F{5}%F{2}%b%F{3}|%F{1}%a%c%u%F{5}%f ' + +theme_precmd () { + vcs_info +} + +export NL=$'\n' + +# Set defaults for display. +# We want the host always, but only the user if we are in an SSH session or root. +P_HOST="%F{green}%m%f" +P_USER='' + +# If we are in an SSH session, we want to show the username +[[ "$SSH_CONNECTION" != '' ]] && P_USER="%{${fg}[magenta]%}%n%f" + +# If we are root, color the user name differently +[[ $UID -eq 0 ]] && P_USER="%{${fg}[red]%}%n%f" + +# If P_USER is set, suffix user with @ giving us user@host +[[ -n "$P_USER" ]] && P_USER="$P_USER@" + +# Combine the prompt parts. Could be just the host, or user@host. +P_PREFIX="$P_USER$P_HOST" + +# Set the color of the current directory +P_DIR="%F{blue}%~%f" + +# Change the color of the prompt if the last command failed +P_SHELL="%(?.%F{green}.%F{red})➜%f" + +# Any extras we want to display +P_EXTRA="" + +# Set the prompt +# user@host /path/to/current/dir (branch) ➜ +export PROMPT="${P_PREFIX} ${P_DIR} %{$reset_color%}${vcs_info_msg_0_}%{$reset_color%}%{${P_EXTRA}%}${NL}${P_SHELL} " + +autoload -U add-zsh-hook +add-zsh-hook precmd theme_precmd diff --git a/install.conf.yaml b/install.conf.yaml index 34408a4..4fec21a 100644 --- a/install.conf.yaml +++ b/install.conf.yaml @@ -19,6 +19,7 @@ ~/.local/share/gnupg: mode: 0700 ~/.local/state: + ~/.local/state/zsh: ~/.ssh: mode: 0700 ~/.ssh/local.d: