diff --git a/config/shared/zsh/zsh_config/aliases b/config/shared/zsh/zsh_config/aliases new file mode 100644 index 0000000..b32ac20 --- /dev/null +++ b/config/shared/zsh/zsh_config/aliases @@ -0,0 +1,45 @@ +# ----------------------------- +# OS-specific aliases for ls +# ----------------------------- +OS_TYPE=$(uname) +if [[ "$OS_TYPE" == "Linux" ]]; then + alias ls='ls --color=auto --group-directories-first' +elif [[ "$OS_TYPE" == "Darwin" ]]; then + alias ls='ls --color=auto' +fi + +alias ll='ls -lF' +alias lla='ll -a' +alias ld='ls -ld */' + +# ----------------------------- +# Vim / Neovim +# ----------------------------- +if command -v nvim >/dev/null 2>&1; then + alias vim='nvim' +else + alias vim='vim' +fi + +# ----------------------------- +# Git aliases +# ----------------------------- +alias g='git' +alias ga='git add' +alias gaa='git add --all' +alias gb='git branch' +alias gcm='git commit -m' +alias gam='git commit -am' +alias gco='git checkout' +alias gd='git diff' +alias gf='git fetch' +alias gl='git pull' +alias gp='git push' +alias gst='git status' +alias glg='git log --graph --oneline --decorate --all' +alias gm='git merge' +alias grb='git rebase' +alias grs='git reset' +alias grv='git remote -v' +alias tree='tree -I node_modules' + diff --git a/config/shared/zsh/zsh_config/keybindings b/config/shared/zsh/zsh_config/keybindings new file mode 100644 index 0000000..b6a70ca --- /dev/null +++ b/config/shared/zsh/zsh_config/keybindings @@ -0,0 +1,16 @@ +# ----------------------------- +# ZLE functions +# ----------------------------- +autoload -U up-line-or-beginning-search +autoload -U down-line-or-beginning-search +zle -N up-line-or-beginning-search +zle -N down-line-or-beginning-search + +# ----------------------------- +# Bind keys for history search +# ----------------------------- +bindkey '^[[A' up-line-or-beginning-search +bindkey '^[OA' up-line-or-beginning-search +bindkey '^[[B' down-line-or-beginning-search +bindkey '^[OB' down-line-or-beginning-search + diff --git a/config/shared/zsh/zsh_config/prompt b/config/shared/zsh/zsh_config/prompt new file mode 100644 index 0000000..2610971 --- /dev/null +++ b/config/shared/zsh/zsh_config/prompt @@ -0,0 +1,15 @@ +# ----------------------------- +# Git prompt function +# ----------------------------- +git_prompt_info() { + if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + local branch=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD) + echo " %F{green}($branch)%f" + fi +} + +# ----------------------------- +# Set prompt +# ----------------------------- +PROMPT='%n@%m%f %F{blue}%~%f$(git_prompt_info) $ ' + diff --git a/config/shared/zsh/zsh_config/zshrc b/config/shared/zsh/zsh_config/zshrc new file mode 100644 index 0000000..efeb1d0 --- /dev/null +++ b/config/shared/zsh/zsh_config/zshrc @@ -0,0 +1,48 @@ +# ----------------------------- +# PATH +# ----------------------------- +export PATH="$PATH:$HOME/bin" + +# ----------------------------- +# Locales +# ----------------------------- +export LANGUAGE="en_US:en" +export LANG=en_US.UTF-8 +export LC_ALL=en_US.UTF-8 + +# ----------------------------- +# Autocomplete +# ----------------------------- +autoload -Uz compinit && compinit +zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # Case insensitive + +# ----------------------------- +# Shell options +# ----------------------------- +setopt autocd +setopt share_history +setopt interactivecomments +setopt PROMPT_SUBST # Enable dynamic prompt expansion + +# ----------------------------- +# Disable conflicting builtins +# ----------------------------- +disable log + +# ----------------------------- +# History +# ----------------------------- +HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history +HISTSIZE=2000 +SAVEHIST=1000 +setopt HIST_IGNORE_ALL_DUPS + +# ----------------------------- +# Source modular components +# ----------------------------- +CONFIG_DIR="$HOME/.config/zsh" + +[ -f "$CONFIG_DIR/aliases" ] && source "$CONFIG_DIR/aliases" +[ -f "$CONFIG_DIR/prompt" ] && source "$CONFIG_DIR/prompt" +[ -f "$CONFIG_DIR/keybindings" ] && source "$CONFIG_DIR/keybindings" + diff --git a/config/shared/zsh b/config/shared/zsh/zshrc_root similarity index 100% rename from config/shared/zsh rename to config/shared/zsh/zshrc_root