From 9c38ebd3ee6e4293f3baa6d9e98d97ae0b77e63c Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Sat, 1 Jul 2023 15:13:16 +0200 Subject: [PATCH] zsh: just use zsh for prompt, deprecating starship --- .config/starship.toml | 74 ------------------------------------------- .tmux.conf | 18 +++++------ .zshrc | 35 ++++++++++++++++---- 3 files changed, 38 insertions(+), 89 deletions(-) delete mode 100644 .config/starship.toml diff --git a/.config/starship.toml b/.config/starship.toml deleted file mode 100644 index a3b9734..0000000 --- a/.config/starship.toml +++ /dev/null @@ -1,74 +0,0 @@ -add_newline = false - - -format = """\ -${env_var.TMUX_WINDOW}\ -$hostname\ -$directory\ -($character)\ -""" - -# $git_branch\ -# $git_commit\ -# $git_state\ -# $git_status\ -right_format = """\ -""" - -[nix_shell] -disabled = true -impure_msg = '[impure shell](bold red)' -pure_msg = '[pure shell](bold green)' -unknown_msg = '[unknown shell](bold yellow)' -format = 'via [☃️ $state( \($name\))](bold blue) ' - -[env_var.TMUX_WINDOW] -default = "" -format = '[ $env_value ]($style) ' -style = 'italic bg:#d1002f fg:#ffffff' - -[custom.sl_status] -command = '''~/bin/starship-sl-status''' -when = false -style = "italic fg:#79AE6F" -format = '[(🌱 $output )]($style)' - -[character] -success_symbol = "%" -error_symbol = "[%](bold red)" - -[line_break] -disabled = true - -[directory] -fish_style_pwd_dir_length = 1 -truncation_length = 1 -truncate_to_repo = false -style = "italic dimmed" - -[git_branch] -format = "[$symbol$branch]($style)" -style = "fg:#559955" -symbol = " " -truncation_length = 16 -truncation_symbol = "" - -[git_commit] -format = "[ $hash$tag]($style) " -style = "fg:#559955" - -[git_state] -style = "" - -[git_status] -format = '([\[$all_status$ahead_behind\]]($style))' -style = "dimmed" - -[hostname] -ssh_only = false -format = "[$hostname](dimmed italic):" -disabled = false - -[kubernetes] -disabled = false -style = "" diff --git a/.tmux.conf b/.tmux.conf index b44348c..5fd908b 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -73,14 +73,14 @@ set -g set-titles on set -g set-titles-string "#H - #T" new -s0 -n 1 nvim --listen $XDG_RUNTIME_DIR/nvim.sock -new-window -n 2 -e TMUX_WINDOW=2 -new-window -n 3 -e TMUX_WINDOW=3 -new-window -n 4 -e TMUX_WINDOW=4 -new-window -n 5 -e TMUX_WINDOW=5 -new-window -n 6 -e TMUX_WINDOW=6 -new-window -n 7 -e TMUX_WINDOW=7 -new-window -n 8 -e TMUX_WINDOW=8 -new-window -n 9 -e TMUX_WINDOW=9 -new-window -n 0 -e TMUX_WINDOW=0 +new-window -n 2 +new-window -n 3 +new-window -n 4 +new-window -n 5 +new-window -n 6 +new-window -n 7 +new-window -n 8 +new-window -n 9 +new-window -n 0 # vim:set ft=tmux: diff --git a/.zshrc b/.zshrc index 53e76f4..a8ee569 100644 --- a/.zshrc +++ b/.zshrc @@ -18,6 +18,8 @@ zi ice wait lucid zi load zsh-users/zsh-history-substring-search zi ice wait lucid zi load nix-community/nix-zsh-completions +zi ice wait lucid +zi snippet https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/plugins/shrink-path/shrink-path.plugin.zsh zstyle ':completion:*' use-cache on zstyle ':completion:*' cache-path ~/.zsh/cache @@ -55,6 +57,8 @@ setopt extended_glob setopt ksh_glob setopt null_glob +export LC_ALL=en_US.UTF-8 + ## Autosuggest # ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#D7CCC8,italic" # ZSH_AUTOSUGGEST_USE_ASYNC=1 @@ -99,7 +103,6 @@ bindkey '^[[B' history-beginning-search-forward bindkey '^P' history-beginning-search-backward bindkey '^N' history-beginning-search-forward bindkey '^g' _jump -bindkey '^_' _cwd_gitroot ## Pager @@ -139,15 +142,35 @@ rg() { /usr/bin/rg -p "$@" | bat } -fix_cursor() { - echo -ne '\e[5 q' +## Prompt + +prompt_chpwd() { + if [[ ${#PWD} < 25 ]]; then + PROMPT_PWD="$PWD" + else + PROMPT_PWD="$(shrink_path -t -l -e "%{%G\e[2;3;38;5;202m\U2026\e[0;2;3m%}")" + fi +} +chpwd_functions+=prompt_chpwd + +prompt_precmd() { + # PROMPT_LABEL="%B$(tmux display-message -p "#I")%b" + PROMPT_LABEL="$HOST" } -precmd_functions+=(fix_cursor) +precmd_functions+=(prompt_precmd) +autoload -Uz vcs_info +chpwd_functions+=vcs_info +precmd_functions+=vcs_info -## Prompt -eval "$(starship init zsh)" +zstyle ':vcs_info:git:*' check-for-changes true +zstyle ':vcs_info:git:*' formats '%F{#559955} %b%u%c%f ' +zstyle ':vcs_info:*' unstagedstr ' %F{#ff0}󰦒' +zstyle ':vcs_info:*' stagedstr ' %F{#9ff}󰐖' + +setopt PROMPT_SUBST +PROMPT=$'%F{#fff}%K{#d1002f}%{\e[3m%} ${PROMPT_LABEL} %{\e[0m%}%S%F{#d1002f}%k%{%G\Ue0ba%}%k%s%f%{\e[2;3m%}${PROMPT_PWD}%{\e[0m%} ${vcs_info_msg_0_}%# ' ## vim export EDITOR=nvim