diff --git a/config/nvim/lua/aleidk/plugins/formatter.lua b/config/nvim/lua/aleidk/plugins/formatter.lua index 1013d94..ffdeaf8 100644 --- a/config/nvim/lua/aleidk/plugins/formatter.lua +++ b/config/nvim/lua/aleidk/plugins/formatter.lua @@ -19,6 +19,7 @@ return { scss = { { "prettierd", "prettier" } }, html = { "prettierd" }, sh = { "shfmt" }, + zsh = { "shfmt" }, markdown = { "markdownlint" }, -- Use the "_" filetype to run formatters on filetypes that don't -- have other formatters configured. diff --git a/config/zsh/aliases/aliases.zsh b/config/zsh/aliases/aliases.zsh index 577d87c..5a41377 100644 --- a/config/zsh/aliases/aliases.zsh +++ b/config/zsh/aliases/aliases.zsh @@ -7,38 +7,38 @@ alias pdw="pwd" # File Managment alias \ - cp='cp -iv' \ - mv='mv -iv' \ - cpr='rsync -za --partial -hh --info=progress2' \ - mvr='rsync -za --remove-source-files --partial -hh --info=progress2' \ - sync='rsync -zau --delete --partial -hh --info=progress2' \ - del='trash -i' \ - rmf='rm -rfI' \ - md='mkdir -pv' \ - ls='eza -lh --color=always --icons --git ' \ - la='eza -alh --color=always --icons --git ' \ - ld='eza -la --no-permissions --no-filesize --no-time --no-time --no-user' \ - mkexec='chmod +x'; + cp='cp -iv' \ + mv='mv -iv' \ + cpr='rsync -za --partial -hh --info=progress2' \ + mvr='rsync -za --remove-source-files --partial -hh --info=progress2' \ + sync='rsync -zau --delete --partial -hh --info=progress2' \ + del='trash -i' \ + rmf='rm -rfI' \ + md='mkdir -pv' \ + ls='eza -lh --color=always --icons --git ' \ + la='eza -alh --color=always --icons --git ' \ + ld='eza -la --no-permissions --no-filesize --no-time --no-time --no-user' \ + mkexec='chmod +x' # Search and Query Files -alias grep="rg --sort path --context 3"; +alias grep="rg --sort path --context 3" # Quicly update Stuff alias vi-ssh="vi ~/.ssh/config" # Query Stuff alias \ - ip='ip -human -color -brief addr' \ - df="duf --hide special --hide-mp '/boot,/boot/*'" \ - du='dust --reverse' \ - du1='dust --reverse --min-size 1M --depth 1' \ - du2='dust --reverse --min-size 1M --depth 2' \ - du3='dust --reverse --min-size 1M --depth 3' \ - cat='bat'; + ip='ip -human -color -brief addr' \ + df="duf --hide special --hide-mp '/boot,/boot/*'" \ + du='dust --reverse' \ + du1='dust --reverse --min-size 1M --depth 1' \ + du2='dust --reverse --min-size 1M --depth 2' \ + du3='dust --reverse --min-size 1M --depth 3' \ + cat='bat' # Misc alias \ - reload='exec $SHELL -l' \ + reload='exec $SHELL -l' # Specific Mac overrides if [[ "$OSTYPE" != 'linux-gnu' ]]; then diff --git a/config/zsh/aliases/git.zsh b/config/zsh/aliases/git.zsh index b7485b6..40605eb 100644 --- a/config/zsh/aliases/git.zsh +++ b/config/zsh/aliases/git.zsh @@ -1,2 +1,19 @@ 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' diff --git a/config/zsh/completions/_globdots b/config/zsh/completions/_globdots new file mode 100644 index 0000000..9b0d4f4 --- /dev/null +++ b/config/zsh/completions/_globdots @@ -0,0 +1 @@ +_comp_options+=(globdots) # With hidden files diff --git a/config/zsh/config/colors.zsh b/config/zsh/config/colors.zsh deleted file mode 100644 index 8a06f9f..0000000 --- a/config/zsh/config/colors.zsh +++ /dev/null @@ -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 -} - diff --git a/config/zsh/config/options.zsh b/config/zsh/config/options.zsh deleted file mode 100644 index 2e6e02a..0000000 --- a/config/zsh/config/options.zsh +++ /dev/null @@ -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 diff --git a/config/zsh/zprofile b/config/zsh/zprofile index 5ecbe2d..278fdfd 100755 --- a/config/zsh/zprofile +++ b/config/zsh/zprofile @@ -15,6 +15,7 @@ export MOZ_ENABLE_WAYLAND=1 export NPM_PACKAGES="$HOME/.npm-packages" export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}" export PNPM_HOME="$HOME/.local/share/pnpm" +. "$HOME/.cargo/env" # Unset manpath so we can inherit from /etc/manpath via the `manpath` # command @@ -33,7 +34,6 @@ update_path "$PNPM_HOME" update_path "$HOME/.local/share/rtx/shims" update_path "$HOME/.spicetify" -. "$HOME/.cargo/env" if [[ $OSTYPE =~ 'darwin' ]]; then eval "$(/opt/homebrew/bin/brew shellenv)" diff --git a/config/zsh/zshrc b/config/zsh/zshrc index a98ccd1..b2c2a63 100755 --- a/config/zsh/zshrc +++ b/config/zsh/zshrc @@ -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 - zmodload zsh/zprof + zmodload zsh/zprof fi -## Stuff I don't know what they're for -# autoload -Uz compinit -# compinit - #--------------------------------------------------------------------# # ZSH Config # #--------------------------------------------------------------------# -# this should before placed before `"$ZSH/oh-my-zsh.sh"` -# Color scheme for syntax highlighting -source ~/.config/zsh/themes/catppuccin_macchiato-zsh-syntax-highlighting.zsh +# set VIM keybindings +bindkey -v +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+=${XDG_CONFIG_HOME:-$DOTS/config}/zsh/completions -# set VIM keybindings -bindkey -v - -# Path to your oh-my-zsh installation. -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 +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 # autocomplete: https://github.com/marlonrichert/zsh-autocomplete/blob/main/.zshrc zstyle ':autocomplete:*' fzf-completion yes zstyle ':autocomplete:*' min-input 1 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 # @@ -87,24 +89,23 @@ source $ZSH/oh-my-zsh.sh # File directory that are needed to source files=( - # zsh - $DOTS/config/zsh/**/*.zsh - # fzf scripts that need to be sourced - $DOTS/scripts/fzf-flatpak - # fzf config file - $DOOTS/config/fzf/fzfrc + # zsh + $DOTS/config/zsh/**/*.zsh + # fzf scripts that need to be sourced + $DOTS/scripts/fzf-flatpak + # fzf config file + $DOOTS/config/fzf/fzfrc ) for file in $files; do - if [[ -f $file ]]; then - emulate -L zsh - source $file - fi + if [[ -f $file ]]; then + emulate -L zsh + source $file + fi done - if [[ "$ZPROF" = true ]]; then - zprof + zprof fi eval "$(starship init zsh)" @@ -112,3 +113,6 @@ eval "$(starship init zsh)" eval "$(zoxide init 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