Created
August 8, 2026 18:34
-
-
Save pkdiv/e86e787a7d17d71970f3970de3f31abd to your computer and use it in GitHub Desktop.
Shell Configs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ```zsh | |
| # ~/.zshrc - Cleaned & Optimized | |
| # Command execution time printed RIGHT-ALIGNED between prompts (seconds with ms precision) | |
| # ------------------------------------------------- | |
| # 0. REQUIRED MODULES | |
| # ------------------------------------------------- | |
| # Needed for $EPOCHREALTIME | |
| zmodload zsh/datetime | |
| # ------------------------------------------------- | |
| # 1. OPTIONS & SHELL BEHAVIOR | |
| # ------------------------------------------------- | |
| setopt autocd | |
| setopt interactivecomments | |
| setopt magicequalsubst | |
| setopt nonomatch | |
| setopt notify | |
| setopt numericglobsort | |
| setopt promptsubst | |
| WORDCHARS='_-' | |
| PROMPT_EOL_MARK="" | |
| # ------------------------------------------------- | |
| # 2. KEYBINDINGS | |
| # ------------------------------------------------- | |
| bindkey -e | |
| bindkey ' ' magic-space | |
| bindkey '^U' backward-kill-line | |
| bindkey '^[[3;5~' kill-word | |
| bindkey '^[[3~' delete-char | |
| bindkey '^[[1;5C' forward-word | |
| bindkey '^[[1;5D' backward-word | |
| bindkey '^[[H' beginning-of-line | |
| bindkey '^[[F' end-of-line | |
| bindkey '^[[Z' undo | |
| # ------------------------------------------------- | |
| # 3. COMPLETION SYSTEM | |
| # ------------------------------------------------- | |
| autoload -Uz compinit | |
| compinit -d ~/.cache/zcompdump | |
| zstyle ':completion:*' menu select | |
| zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' | |
| zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" | |
| # ------------------------------------------------- | |
| # 4. HISTORY | |
| # ------------------------------------------------- | |
| HISTFILE=~/.zsh_history | |
| HISTSIZE=1000 | |
| SAVEHIST=2000 | |
| setopt hist_expire_dups_first | |
| setopt hist_ignore_dups | |
| setopt hist_ignore_space | |
| setopt hist_verify | |
| alias history="history 0" | |
| # ------------------------------------------------- | |
| # 5. EXECUTION TIMER (seconds, ms precision) | |
| # ------------------------------------------------- | |
| preexec() { | |
| _cmd_start_time=$EPOCHREALTIME | |
| # full command line is in $1 | |
| case "$1" in | |
| clear|reset) | |
| _skip_timer=1 | |
| ;; | |
| *) | |
| _skip_timer=0 | |
| ;; | |
| esac | |
| } | |
| # ------------------------------------------------- | |
| # 6. TERMINAL TITLE | |
| # ------------------------------------------------- | |
| case "$TERM" in | |
| xterm*|rxvt*|gnome*|alacritty) | |
| TERM_TITLE=$'\e]0;%n: %~\a' | |
| ;; | |
| esac | |
| # ------------------------------------------------- | |
| # 7. PRECMD (RIGHT-ALIGNED TIMER OUTPUT) | |
| # ------------------------------------------------- | |
| precmd() { | |
| print -Pnr -- "$TERM_TITLE" | |
| [[ -n "$_cmd_start_time" ]] || return | |
| (( _skip_timer )) && { unset _cmd_start_time _skip_timer; return; } | |
| local elapsed=$(( EPOCHREALTIME - _cmd_start_time )) | |
| unset _cmd_start_time _skip_timer | |
| # Format: x.xxx s | |
| local msg | |
| printf -v msg "⏱ %.3f s" "$elapsed" | |
| local cols=${COLUMNS:-$(tput cols 2>/dev/null)} | |
| local pad=$(( cols - ${#msg} )) | |
| (( pad < 1 )) && pad=1 | |
| printf "%*s" "$pad" "" | |
| print -P "%F{240}${msg}%f" | |
| } | |
| # ------------------------------------------------- | |
| # 8. PROMPT CONFIGURATION | |
| # ------------------------------------------------- | |
| virtualenv_info() { | |
| [[ -n "$VIRTUAL_ENV" ]] && echo "%F{yellow}($(basename $VIRTUAL_ENV))%f " | |
| } | |
| configure_prompt() { | |
| case "$PROMPT_ALTERNATIVE" in | |
| twoline) | |
| PROMPT=$'%F{%(#.blue.green)}┌──(%B%F{%(#.red.blue)}%n%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\PROMPT=$'%F{%(#.blue.green)}┌──(%B%F{%(#.red.blue)}%n%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.ble.green)}]\n└─$(virtualenv_info)%B%(#.%F{red}#.%F{blue}$)%b%F{reset} ' | |
| ;; | |
| oneline) | |
| PROMPT=$'%B%F{%(#.red.blue)}%n%b%F{reset}:%B%F{%(#.blue.green)}%~%b%F{reset} $(virtualenv_info)%(#.#.$) ' | |
| ;; | |
| esac | |
| } | |
| PROMPT_ALTERNATIVE=twoline | |
| configure_prompt | |
| # ------------------------------------------------- | |
| # 9. EXTERNAL PLUGINS | |
| # ------------------------------------------------- | |
| if [[ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]]; then | |
| source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | |
| fi | |
| if [[ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]]; then | |
| source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh | |
| ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999' | |
| fi | |
| # ------------------------------------------------- | |
| # 10. ALIASES | |
| # ------------------------------------------------- | |
| alias ls='ls --color=auto' | |
| alias ll='ls -l' | |
| alias la='ls -A' | |
| alias grep='grep --color=auto' | |
| # ------------------------------------------------- | |
| # 11. PROMPT TOGGLE (Ctrl+P) | |
| # ------------------------------------------------- | |
| toggle_oneline_prompt() { | |
| if [[ "$PROMPT_ALTERNATIVE" = oneline ]]; then | |
| PROMPT_ALTERNATIVE=twoline | |
| else | |
| PROMPT_ALTERNATIVE=oneline | |
| fi | |
| configure_prompt | |
| zle reset-prompt | |
| } | |
| zle -N toggle_oneline_prompt | |
| bindkey ^P toggle_oneline_prompt | |
| # ------------------------------------------------- | |
| # GENERIC PATHS AND ENVIRONMENT VARIABLES | |
| # ------------------------------------------------- | |
| export PATH="$(npm config get prefix)/bin:$PATH" | |
| . "$HOME/.local/bin/env" | |
| ``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment