- Add ~/.zshrc + Configure on how the `history` works + Enable nicer `cd` and globbing behavior + Enable tab completion, and make them feel nicer + Enable VI mode and add some VI-like key bindings - Add ~/.zlogout clearing the screen - Add ~/.config/zsh/.zshrc and make it dispatch to ~/.zshrc to make `zsh` use the same configuration even on more recent Debian/Ubuntu machines that do not look for ~/.zshrc any more - Ensure ~/.local/state/zsh/ exists
74 lines
1.8 KiB
Shell
74 lines
1.8 KiB
Shell
#!/bin/sh
|
|
|
|
# Aliases used in all kinds of shells
|
|
|
|
|
|
# Manage the bare `git` repository in ~/ holding the dotfiles
|
|
alias dotfiles='git --git-dir=$DOTFILES_DIR --work-tree=$HOME'
|
|
|
|
|
|
|
|
forget() { # the current history and restore $HISTFILE from disk
|
|
if [ -n "$BASH_VERSION" ]; then
|
|
history -c
|
|
history -r
|
|
elif [ -n "$ZSH_VERSION" ]; then
|
|
_histsize=$HISTSIZE
|
|
HISTSIZE=0 # because shrinking the list to 0 discards all entries
|
|
HISTSIZE=$_histsize
|
|
unset _histsize
|
|
fc -R "$HISTFILE"
|
|
fi
|
|
}
|
|
|
|
if [ -n "$ZSH_VERSION" ]; then
|
|
alias forget=' forget' # Leading space => The invocation itself is forgotten because of `setopt HIST_IGNORE_SPACE`
|
|
fi
|
|
|
|
|
|
|
|
alias path='echo $PATH | tr ":" "\n"'
|
|
|
|
|
|
# Easier `cd` movements
|
|
alias ..='cd ..'
|
|
alias ...='cd ../..'
|
|
alias ....='cd ../../..'
|
|
alias .....='cd ../../../..'
|
|
|
|
|
|
# Use human-readable sizes
|
|
alias df='df --human-readable'
|
|
alias du='du --human-readable'
|
|
alias free='free --human'
|
|
|
|
|
|
# Make the terminal more colorful
|
|
|
|
alias diff='diff --color=auto'
|
|
alias grep='grep --color=auto --exclude-dir=.git'
|
|
alias ip='ip -color=auto'
|
|
|
|
if _command_exists dircolors; then
|
|
|
|
# Compute `$LS_COLORS` only once because this file is also sourced
|
|
# by every non-interactive `bash` via `$BASH_ENV` (e.g., ":!cmd" in `vi`)
|
|
if [ -z "${LS_COLORS:-}" ]; then
|
|
if [ -r "$XDG_CONFIG_HOME/dircolors" ]; then
|
|
eval "$(dircolors -b "$XDG_CONFIG_HOME/dircolors")"
|
|
else
|
|
eval "$(dircolors -b)"
|
|
fi
|
|
fi
|
|
|
|
alias ls='ls --color=auto'
|
|
|
|
fi
|
|
|
|
|
|
# Add common `ls` utilities
|
|
alias l='ls --classify --format=vertical'
|
|
alias la='ls --classify --format=vertical --almost-all'
|
|
alias lal='ls --classify --format=long --almost-all'
|
|
alias ll='ls --classify --format=long'
|
|
alias lla='lal'
|