Update zsh config to be more minimal

- config is more centrilize in zshrc
- it doesn't depend on oh-my-zsh
This commit is contained in:
Alexander Navarro 2024-02-20 13:18:05 -03:00
parent 3b99ffe395
commit 5dcbc3a0b2
8 changed files with 123 additions and 180 deletions

View file

@ -19,6 +19,7 @@ return {
scss = { { "prettierd", "prettier" } }, scss = { { "prettierd", "prettier" } },
html = { "prettierd" }, html = { "prettierd" },
sh = { "shfmt" }, sh = { "shfmt" },
zsh = { "shfmt" },
markdown = { "markdownlint" }, markdown = { "markdownlint" },
-- Use the "_" filetype to run formatters on filetypes that don't -- Use the "_" filetype to run formatters on filetypes that don't
-- have other formatters configured. -- have other formatters configured.

View file

@ -18,10 +18,10 @@ alias \
ls='eza -lh --color=always --icons --git ' \ ls='eza -lh --color=always --icons --git ' \
la='eza -alh --color=always --icons --git ' \ la='eza -alh --color=always --icons --git ' \
ld='eza -la --no-permissions --no-filesize --no-time --no-time --no-user' \ ld='eza -la --no-permissions --no-filesize --no-time --no-time --no-user' \
mkexec='chmod +x'; mkexec='chmod +x'
# Search and Query Files # Search and Query Files
alias grep="rg --sort path --context 3"; alias grep="rg --sort path --context 3"
# Quicly update Stuff # Quicly update Stuff
alias vi-ssh="vi ~/.ssh/config" alias vi-ssh="vi ~/.ssh/config"
@ -34,11 +34,11 @@ alias \
du1='dust --reverse --min-size 1M --depth 1' \ du1='dust --reverse --min-size 1M --depth 1' \
du2='dust --reverse --min-size 1M --depth 2' \ du2='dust --reverse --min-size 1M --depth 2' \
du3='dust --reverse --min-size 1M --depth 3' \ du3='dust --reverse --min-size 1M --depth 3' \
cat='bat'; cat='bat'
# Misc # Misc
alias \ alias \
reload='exec $SHELL -l' \ reload='exec $SHELL -l'
# Specific Mac overrides # Specific Mac overrides
if [[ "$OSTYPE" != 'linux-gnu' ]]; then if [[ "$OSTYPE" != 'linux-gnu' ]]; then

View file

@ -1,2 +1,19 @@
alias \ alias \
glf='git log -p --' glf='git log -p --' \
gs='git status' \
ga='git add' \
gp='git push' \
gpo='git push origin' \
gtd='git tag --delete' \
gtdr='git tag --delete origin' \
gr='git branch -r' \
gplo='git pull origin' \
gb='git branch ' \
gc='git commit' \
gd='git diff' \
gco='git checkout ' \
gl='git log' \
gr='git remote' \
grs='git remote show' \
glo='git log --pretty="oneline"' \
glol='git log --graph --oneline --decorate'

View file

@ -0,0 +1 @@
_comp_options+=(globdots) # With hidden files

View file

@ -1,41 +0,0 @@
define_colors() {
if command -v tput > /dev/null 2>&1; then
# colors
BLK="$(tput setaf 0)"
RED="$(tput setaf 1)"
GRN="$(tput setaf 2)"
YLW="$(tput setaf 3)"
BLU="$(tput setaf 4)"
MGN="$(tput setaf 5)"
CYN="$(tput setaf 6)"
WHT="$(tput setaf 7)"
# formatting
RST="$(tput sgr0)" # reset all formatting
BLD="$(tput bold)" # makes the text bold
DIM="$(tput dim)" # makes the text dim
SUL="$(tput smul)" # set underline
RUL="$(tput rmul)" # remove underline
REV="$(tput rev)" # reverses fg and bg colors
SHL="$(tput smso)" # start standout mode (set highlight)
EHL="$(tput rmso)" # end standout mode(remove highlight)
else
BLK="\033[0;30m"
RED="\033[0;31m"
GRN="\033[0;32m"
YLW="\033[0;33m"
BLU="\033[0;34m"
MGN="\033[0;35m"
CYN="\033[0;36m"
WHT="\033[0;37m"
RST="\033[0m"
BLD="\033[1m"
DIM="\033[2m"
SUL="\033[4m"
RUL="\033[24m"
REV="\033[7m"
SHL="\033[7m"
EHL="\033[27m"
fi
}

View file

@ -1,39 +0,0 @@
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
# setopt BANG_HIST
setopt EXTENDED_HISTORY
# setopt HIST_EXPIRE_DUPS_FIRST
# setopt HIST_IGNORE_DUPS
# setopt HIST_FIND_NO_DUPS
# setopt HIST_IGNORE_ALL_DUPS
# setopt HIST_IGNORE_SPACE
# setopt HIST_SAVE_NO_DUPS
# setopt HIST_VERIFY
# setopt SHARE_HISTORY
# Navigation
setopt AUTO_CD
setopt AUTO_PUSHD
setopt CDABLE_VARS
setopt PUSHD_IGNORE_DUPS
setopt PUSHD_SILENT
# Completion
setopt AUTO_LIST # Automatically list choices on ambiguous completion.
# setopt CORRECT # Turn on spelling correction for command.
setopt COMPLETE_IN_WORD # Complete from both ends of a word.
setopt GLOB_COMPLETE # Show autocompletion menu with globs
setopt MENU_COMPLETE # Automatically highlight first element of completion menu
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%F{cyan}%BSorry, no matches for: %d%b%f'
zstyle ':completion:*' rehash true
zstyle ':completion:*' use-cache on
setopt autocd beep extendedglob notify
zstyle ':completion:*' group-name ''
zstyle :compinstall filename '/home/aleidk/.zshrc'
setopt GLOB_DOTS

View file

@ -15,6 +15,7 @@ export MOZ_ENABLE_WAYLAND=1
export NPM_PACKAGES="$HOME/.npm-packages" export NPM_PACKAGES="$HOME/.npm-packages"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}" export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
export PNPM_HOME="$HOME/.local/share/pnpm" export PNPM_HOME="$HOME/.local/share/pnpm"
. "$HOME/.cargo/env"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` # Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command # command
@ -33,7 +34,6 @@ update_path "$PNPM_HOME"
update_path "$HOME/.local/share/rtx/shims" update_path "$HOME/.local/share/rtx/shims"
update_path "$HOME/.spicetify" update_path "$HOME/.spicetify"
. "$HOME/.cargo/env"
if [[ $OSTYPE =~ 'darwin' ]]; then if [[ $OSTYPE =~ 'darwin' ]]; then
eval "$(/opt/homebrew/bin/brew shellenv)" eval "$(/opt/homebrew/bin/brew shellenv)"

View file

@ -1,85 +1,87 @@
# Start mesuring bottlenecks #/usr/share/fzf/shell/key-bindings.zsh/usr/share/fzf/shell/key-bindings.zsh Start mesuring bottlenecks
if [[ "$ZPROF" = true ]]; then if [[ "$ZPROF" = true ]]; then
zmodload zsh/zprof zmodload zsh/zprof
fi fi
## Stuff I don't know what they're for
# autoload -Uz compinit
# compinit
#--------------------------------------------------------------------# #--------------------------------------------------------------------#
# ZSH Config # # ZSH Config #
#--------------------------------------------------------------------# #--------------------------------------------------------------------#
# this should before placed before `"$ZSH/oh-my-zsh.sh"` # set VIM keybindings
# Color scheme for syntax highlighting bindkey -v
source ~/.config/zsh/themes/catppuccin_macchiato-zsh-syntax-highlighting.zsh export KEYTIMEOUT=1
autoload -Uz edit-command-line
zle -N edit-command-line
bindkey -M vicmd V edit-command-line # edits files in vim, hit Shift+v in normal mode
# Add vim text objects
autoload -Uz select-bracketed select-quoted
zle -N select-quoted
zle -N select-bracketed
for km in viopp visual; do
bindkey -M $km -- '-' vi-up-line-or-history
for c in {a,i}${(s..)^:-\'\"\`\|,./:;=+@}; do
bindkey -M $km $c select-quoted
done
for c in {a,i}${(s..)^:-'()[]{}<>bB'}; do
bindkey -M $km $c select-bracketed
done
done
# History
export HISTFILE="$HOME/.zsh_history" # History filepath
export HISTSIZE=10000 # Maximum events for internal history
export SAVEHIST=10000 # Maximum events in history file
setopt EXTENDED_HISTORY
# Navigation
setopt AUTO_CD
setopt AUTO_PUSHD
setopt CDABLE_VARS
setopt PUSHD_SILENT
# Completion
setopt AUTO_LIST # Automatically list choices on ambiguous completion.
# setopt CORRECT # Turn on spelling correction for command.
setopt COMPLETE_IN_WORD # Complete from both ends of a word.
setopt GLOB_COMPLETE # Show autocompletion menu with globs
setopt MENU_COMPLETE # Automatically highlight first element of completion menu
fpath+=${ZSH_CUSTOM:-${ZSH:-$XDG_DATA_HOME/oh-my-zsh}/custom}/plugins/zsh-completions/src fpath+=${ZSH_CUSTOM:-${ZSH:-$XDG_DATA_HOME/oh-my-zsh}/custom}/plugins/zsh-completions/src
fpath+=${XDG_CONFIG_HOME:-$DOTS/config}/zsh/completions fpath+=${XDG_CONFIG_HOME:-$DOTS/config}/zsh/completions
# set VIM keybindings zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
bindkey -v zstyle ':completion:*:warnings' format '%F{cyan}%BSorry, no matches for: %d%b%f'
zstyle ':completion:*' rehash true
# Path to your oh-my-zsh installation. zstyle ':completion:*' use-cache on
export ZSH="$HOME/.local/share/oh-my-zsh"
ZSH_THEME="gozilla"
# Case-sensitive completion must be off. _ and - will be interchangeable.
HYPHEN_INSENSITIVE="true"
DISABLE_AUTO_TITLE="true"
# Uncomment the following line to display red dots whilst waiting for completion.
COMPLETION_WAITING_DOTS="true"
# Read Git repos much faster.
DISABLE_UNTRACKED_FILES_DIRTY="true"
# search if exist an alias for the executed command
ZSH_ALIAS_FINDER_AUTOMATIC=true
#--------------------------------------------------------------------#
# Plugin Config #
#--------------------------------------------------------------------#
# VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true
# VI_MODE_SET_CURSOR=true
ZSHZ_TILDE=1
plugins=(
alias-finder
bgnotify
colored-man-pages
docker
docker-compose
fd
fzf
# git # disabled because I only ocasionally use git from the terminal
safe-paste # don't run code when pasting
systemd
# z # TODO: replace plugin with zoxide
zsh-autocomplete
zsh-autopair
zsh-autosuggestions
zsh-completions
zsh-interactive-cd
zsh-syntax-highlighting
)
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
export HISTCONTROL=ignoreboth:erasedups
# autocomplete: https://github.com/marlonrichert/zsh-autocomplete/blob/main/.zshrc # autocomplete: https://github.com/marlonrichert/zsh-autocomplete/blob/main/.zshrc
zstyle ':autocomplete:*' fzf-completion yes zstyle ':autocomplete:*' fzf-completion yes
zstyle ':autocomplete:*' min-input 1 zstyle ':autocomplete:*' min-input 1
zstyle ':autocomplete:*' widget-style menu-select # Tab select instead of autocomplete zstyle ':autocomplete:*' widget-style menu-select # Tab select instead of autocomplete
source $ZSH/oh-my-zsh.sh setopt autocd beep extendedglob notify
zstyle ':completion:*' group-name ''
zstyle :compinstall filename '/home/aleidk/.zshrc'
zmodload zsh/complist
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
# FZF config
source /usr/share/fzf/shell/key-bindings.zsh
autoload -U compinit
compinit
setopt GLOB_DOTS
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
#--------------------------------------------------------------------# #--------------------------------------------------------------------#
# Start Stuff # # Start Stuff #
@ -102,7 +104,6 @@ for file in $files; do
fi fi
done done
if [[ "$ZPROF" = true ]]; then if [[ "$ZPROF" = true ]]; then
zprof zprof
fi fi
@ -112,3 +113,6 @@ eval "$(starship init zsh)"
eval "$(zoxide init zsh)" eval "$(zoxide init zsh)"
eval "$(mise activate zsh)" eval "$(mise activate zsh)"
# Load syntax highlight at the end so other configuration can use it
# Color scheme for syntax highlighting
source ~/.config/zsh/themes/catppuccin_macchiato-zsh-syntax-highlighting.zsh