diff --git a/dot_zshrc b/dot_zshrc new file mode 100644 index 0000000..de765db --- /dev/null +++ b/dot_zshrc @@ -0,0 +1,3 @@ +# Put ZSH dotfiles into "~/.config/zsh" +export ZDOTDIR="$HOME/.config/zsh" +source "$ZDOTDIR/.zshrc" diff --git a/private_dot_config/zsh/alias.zsh b/private_dot_config/zsh/alias.zsh new file mode 100644 index 0000000..943e0bb --- /dev/null +++ b/private_dot_config/zsh/alias.zsh @@ -0,0 +1,2 @@ +alias ls="ls --color --group-directories-first" +alias l="ls -l --almost-all --human-readable" diff --git a/private_dot_config/zsh/dot_zshrc b/private_dot_config/zsh/dot_zshrc new file mode 100644 index 0000000..69ba89b --- /dev/null +++ b/private_dot_config/zsh/dot_zshrc @@ -0,0 +1,18 @@ +source "$ZDOTDIR/history.zsh" +source "$ZDOTDIR/alias.zsh" +source "$ZDOTDIR/plugins.zsh" + +# Bind Ctrl-left/right arrow to move back/formward one word +# https://unix.stackexchange.com/a/140499 +bindkey "^[[1;5C" forward-word +bindkey "^[[1;5D" backward-word + +# Enable the autocompletion and make it case insensitive +# https://superuser.com/a/1092328 +autoload -U compinit && compinit +zstyle ":completion:*" matcher-list "m:{a-z}={A-Za-z}" + +# Load `ls` color when autocompleting directories +# https://unix.stackexchange.com/a/447002 +eval "$(dircolors)" +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} diff --git a/private_dot_config/zsh/history.zsh b/private_dot_config/zsh/history.zsh new file mode 100644 index 0000000..dd3bc6f --- /dev/null +++ b/private_dot_config/zsh/history.zsh @@ -0,0 +1,16 @@ +# Define the history file path +HISTFILE="$HOME/.cache/zsh/.zsh_history" +[ ! -d "$HOME/.cache/zsh" ] && mkdir -p "$HOME/.cache/zsh" +[ ! -f "$HISTFILE" ] && touch $HISTFILE + +HISTSIZE=5000 +SAVEHIST=$HISTSIZE + +HISTDUP=erase +setopt appendhistory +setopt sharehistory +setopt hist_ignore_space +setopt hist_ignore_all_dups +setopt hist_save_no_dups +setopt hist_ignore_dups +setopt hist_find_no_dups diff --git a/private_dot_config/zsh/plugins.zsh b/private_dot_config/zsh/plugins.zsh new file mode 100644 index 0000000..00acae3 --- /dev/null +++ b/private_dot_config/zsh/plugins.zsh @@ -0,0 +1,20 @@ +# Zinit package manager +# https://github.com/zdharma-continuum/zinit +ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git" +[ ! -d $ZINIT_HOME ] && mkdir -p "$(dirname $ZINIT_HOME)" +[ ! -d $ZINIT_HOME/.git ] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +source "${ZINIT_HOME}/zinit.zsh" + +# Syntax highlighting +zinit ice depth=1; zinit light "zsh-users/zsh-syntax-highlighting" + +# Command completions +zinit ice depth=1; zinit light "zsh-users/zsh-completions" + +# History autosuggestions +zinit ice depth=1; zinit light "zsh-users/zsh-autosuggestions" + +# Use fzf for completion +zinit ice depth=1; zinit light "Aloxaf/fzf-tab" +zstyle ":fzf-tab:complete:cd:*" fzf-preview "ls --color $realpath" +zstyle ":completion:*" menu no