ZSH config overhaul

- .zshrc: Use zinit package manager
- .zshrc: Reorg - remove comments, ZSH, zinit, configs batched together
- .zshrc: Better completions
- .zshrc: More plugins: colored-man-pages, command-not-found, kitty,
  podman, rust, timer, fd, systemd
- .profile: Autoload brew applications on MacOs
- p10k: Transient prompt + dotted lines
This commit is contained in:
Pratik Tripathy
2024-06-28 18:34:43 +05:30
parent d2c56360d9
commit b7fc209c93
3 changed files with 77 additions and 85 deletions

View File

@@ -1,8 +1,8 @@
# Generated by Powerlevel10k configuration wizard on 2024-01-15 at 21:46 IST. # Generated by Powerlevel10k configuration wizard on 2024-06-28 at 15:57 IST.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 43791. # Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 43791.
# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 24h time, # Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 12h time,
# 2 lines, solid, left frame, darkest-ornaments, compact, many icons, concise, # 2 lines, dotted, left frame, darkest-ornaments, sparse, many icons, concise,
# instant_prompt=quiet. # transient_prompt, instant_prompt=verbose.
# Type `p10k configure` to generate another config. # Type `p10k configure` to generate another config.
# #
# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate # Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate
@@ -135,7 +135,7 @@
typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true typeset -g POWERLEVEL9K_ICON_BEFORE_CONTENT=true
# Add an empty line before each prompt. # Add an empty line before each prompt.
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=false typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
# Connect left prompt lines with these symbols. # Connect left prompt lines with these symbols.
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='%238F╭─' typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX='%238F╭─'
@@ -164,7 +164,7 @@
# the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false # the number of prompt lines. You'll probably want to set POWERLEVEL9K_SHOW_RULER=false
# if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact # if using this. You might also like POWERLEVEL9K_PROMPT_ADD_NEWLINE=false for more compact
# prompt. # prompt.
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='' typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR='·'
if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then if [[ $POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_CHAR != ' ' ]]; then
# The color of the filler. # The color of the filler.
typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=238 typeset -g POWERLEVEL9K_MULTILINE_FIRST_PROMPT_GAP_FOREGROUND=238
@@ -788,7 +788,7 @@
# #
# These variables correspond to the last line of the output of `todo.sh -p ls`: # These variables correspond to the last line of the output of `todo.sh -p ls`:
# #
# todo: 24 of 42 tasks shown # TODO: 24 of 42 tasks shown
# #
# Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT. # Here 24 is P9K_TODO_FILTERED_TASK_COUNT and 42 is P9K_TODO_TOTAL_TASK_COUNT.
# #
@@ -1499,7 +1499,7 @@
# Current time color. # Current time color.
typeset -g POWERLEVEL9K_TIME_FOREGROUND=66 typeset -g POWERLEVEL9K_TIME_FOREGROUND=66
# Format for the current time: 09:51:02. See `man 3 strftime`. # Format for the current time: 09:51:02. See `man 3 strftime`.
typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%H:%M:%S}' typeset -g POWERLEVEL9K_TIME_FORMAT='%D{%I:%M:%S %p}'
# If set to true, time will update when you hit enter. This way prompts for the past # If set to true, time will update when you hit enter. This way prompts for the past
# commands will contain the start times of their commands as opposed to the default # commands will contain the start times of their commands as opposed to the default
# behavior where they contain the end times of their preceding commands. # behavior where they contain the end times of their preceding commands.
@@ -1548,7 +1548,7 @@
# - always: Trim down prompt when accepting a command line. # - always: Trim down prompt when accepting a command line.
# - same-dir: Trim down prompt when accepting a command line unless this is the first command # - same-dir: Trim down prompt when accepting a command line unless this is the first command
# typed after changing current working directory. # typed after changing current working directory.
typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=off typeset -g POWERLEVEL9K_TRANSIENT_PROMPT=always
# Instant prompt mode. # Instant prompt mode.
# #
@@ -1560,7 +1560,7 @@
# - verbose: Enable instant prompt and print a warning when detecting console output during # - verbose: Enable instant prompt and print a warning when detecting console output during
# zsh initialization. Choose this if you've never tried instant prompt, haven't # zsh initialization. Choose this if you've never tried instant prompt, haven't
# seen the warning, or if you are unsure what this all means. # seen the warning, or if you are unsure what this all means.
typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet typeset -g POWERLEVEL9K_INSTANT_PROMPT=verbose
# Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized. # Hot reload allows you to change POWERLEVEL9K options after Powerlevel10k has been initialized.
# For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload # For example, you can type POWERLEVEL9K_BACKGROUND=red and see your prompt turn red. Hot reload

View File

@@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
[ ! -f "/home/linuxbrew/.linuxbrew/bin/brew" ] || eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" [ ! -f "/home/linuxbrew/.linuxbrew/bin/brew" ] || eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
[ ! -f "/opt/homebrew/bin/brew" ] || eval "$(/opt/homebrew/bin/brew shellenv)"
# set PATH so it includes user's private bin if it exists # set PATH so it includes user's private bin if it exists
[ ! -d "$HOME/bin" ] || PATH="$HOME/bin:$PATH" [ ! -d "$HOME/bin" ] || PATH="$HOME/bin:$PATH"

View File

@@ -2,6 +2,31 @@
# I'm not using a separate .zprofile; reuse the .profile instead # I'm not using a separate .zprofile; reuse the .profile instead
[[ ! -f "$HOME/.profile" ]] || source "$HOME/.profile" [[ ! -f "$HOME/.profile" ]] || source "$HOME/.profile"
# ZSH Options
bindkey -v # enable vi-mode
setopt +o nomatch
ZSH_THEME="powerlevel10k/powerlevel10k"
CASE_SENSITIVE="true"
DISABLE_UPDATE_PROMPT="true"
COMPLETION_WAITING_DOTS="true"
HIST_STAMPS="dd.mm.yyyy" # see 'man strftime' for details.
VI_MODE_SET_CURSOR=true
VI_MODE_CURSOR_INSERT=3
# ZSH History
export HISTSIZE=10000000
export SAVEHIST=$HISTSIZE
export HISTFILE="$XDG_STATE_HOME/shell/zsh_history"
setopt appendhistory # Append rather than overwriting
setopt sharehistory # Share history between all sessions.
setopt extended_history # Write the history file in the ":start:elapsed;command" format.
setopt inc_append_history # Write to the history file immediately, not when the shell exits.
setopt hist_reduce_blanks # Remove superfluous blanks before recording entry.
setopt hist_verify # Don't execute immediately upon history expansion.
setopt hist_ignore_space # Don't add commands that start with whitespace to history
setopt hist_find_no_dups # Don't show duplicate commands when searching history
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. # Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n] # Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below. # confirmations, etc.) must go above this block; everything else may go below.
@@ -9,97 +34,59 @@ if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi fi
# Path to your oh-my-zsh installation. # Zinit ZSH Plugin Manager
export ZSH="$XDG_DATA_HOME/shell/oh-my-zsh" ZINIT_HOME="${XDG_DATA_HOME}/shell/zinit/zinit.git"
export ZSH_CUSTOM="$ZSH/custom" if [[ ! -d "$ZINIT_HOME" ]]; then
source "${ZSH_CUSTOM}/themes/powerlevel10k/powerlevel10k.zsh-theme" mkdir -p "$(dirname $ZINIT_HOME)"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
fi
source "${ZINIT_HOME}/zinit.zsh"
ZSH_THEME="powerlevel10k/powerlevel10k" # Zinit Plugins
zinit ice depth=1; zinit light romkatv/powerlevel10k
zinit light zdharma-continuum/fast-syntax-highlighting
zinit light zsh-users/zsh-completions
zinit light zsh-users/zsh-autosuggestions
# Uncomment the following line to use case-sensitive completion. # Oh-my-zsh plugins
CASE_SENSITIVE="true" zi snippet OMZP::colored-man-pages
zi snippet OMZP::command-not-found
zi snippet OMZP::gitignore
zi snippet OMZP::kitty
zi snippet OMZP::podman
zi snippet OMZP::rust
zi snippet OMZP::sudo
zi snippet OMZP::systemd
zi snippet OMZP::timer
zi snippet OMZP::vi-mode
zi snippet https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/per-directory-history/per-directory-history.zsh
# Uncomment the following line to use hyphen-insensitive completion. zi ice as"completion"
# Case-sensitive completion must be off. _ and - will be interchangeable. zi snippet OMZP::fd/_fd
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to automatically update without prompting.
DISABLE_UPDATE_PROMPT="true"
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# see 'man strftime' for details.
HIST_STAMPS="dd.mm.yyyy"
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
plugins=(
git
gitignore
docker
docker-compose
per-directory-history
sudo
vi-mode
dotnet
exercism
)
VI_MODE_SET_CURSOR=true
VI_MODE_CURSOR_INSERT=3
HISTORY_BASE="$XDG_STATE_HOME/shell/per-directory-history" HISTORY_BASE="$XDG_STATE_HOME/shell/per-directory-history"
TIMER_PRECISION=3; TIMER_FORMAT='[%d]'
# NOTE: Should be exported before sourcing oh-my-zsh, to avoid the dumpfiles on $HOME # ZSH Auto-completion settings
export ZSH_COMPDUMP="$XDG_CACHE_HOME/zsh/zcompdump-$HOST" autoload -Uz compinit
compinit -d "$XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION"
_comp_options+=(globdots) # Include hidden files
zmodload zsh/complist
zinit cdreplay -q
source "$ZSH/oh-my-zsh.sh" # Completion styling
zstyle ':completion::complete:*' gain-privileges 1 menu select cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
source "$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh" zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' # Case INsensitive completion match
source "$(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Add color to completion suggestions
# To customize prompt, run `p10k configure` # To customize prompt, run `p10k configure`
[[ ! -f "$XDG_CONFIG_HOME/shell/p10k.zsh" ]] || source "$XDG_CONFIG_HOME/shell/p10k.zsh" [[ ! -f "$XDG_CONFIG_HOME/shell/p10k.zsh" ]] || source "$XDG_CONFIG_HOME/shell/p10k.zsh"
# User configuration # User configuration
setopt +o nomatch
# Higher History
export HISTSIZE=10000000
export SAVEHIST=10000000
export HISTFILE="$XDG_STATE_HOME/shell/zsh_history"
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
setopt HIST_IGNORE_SPACE # Don't add commands that start with whitespace to history
# enable vi-mode
bindkey -v
# Add brew provided autocompletions to path # Add brew provided autocompletions to path
[[ ! -d "/home/linuxbrew/.linuxbrew/share/zsh/site-functions" ]] || FPATH="/home/linuxbrew/.linuxbrew/share/zsh/site-functions:$FPATH" [[ ! -d "/home/linuxbrew/.linuxbrew/share/zsh/site-functions" ]] || FPATH="/home/linuxbrew/.linuxbrew/share/zsh/site-functions:$FPATH"
# Auto/tab completions
autoload -Uz compinit
zstyle ':completion::complete:*' gain-privileges 1 menu select cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
zmodload zsh/complist
compinit -d "$XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION"
_comp_options+=(globdots) # Include hidden files
# [ctrl+r]: Search command history # [ctrl+r]: Search command history
# [ctrl+t]: fzf & over the files & directories under the current one & paste it to prompt # [ctrl+t]: fzf & over the files & directories under the current one & paste it to prompt
# [alt+c] : fzf & cd into a directory under the current one # [alt+c] : fzf & cd into a directory under the current one
@@ -110,6 +97,10 @@ command -v zoxide >/dev/null && eval "$(zoxide init --cmd cd zsh)"
# Source aliases and shell functions # Source aliases and shell functions
for alias_file in "$XDG_CONFIG_HOME"/shell/*.sh; do source "$alias_file"; done for alias_file in "$XDG_CONFIG_HOME"/shell/*.sh; do source "$alias_file"; done
# Keybindings
bindkey '^f' autosuggest-accept #
bindkey '^p' history-search-backward # Ctrl+p gets the last history match
bindkey '^n' history-search-forward # Ctrl+n gets the next history match
# TIP: Following should be executed AFTER the aliases are sourced # TIP: Following should be executed AFTER the aliases are sourced
command -v op >/dev/null && bindkey -s '^o' ' op\n' # Fuzzyfind projects and open in nvim command -v op >/dev/null && bindkey -s '^o' ' op\n' # Fuzzyfind projects and open in nvim
command -v pnew >/dev/null && bindkey -s '^[o' ' pnew\n' # Create a new project quickly command -v pnew >/dev/null && bindkey -s '^[o' ' pnew\n' # Create a new project quickly