diff options
Diffstat (limited to '.config')
-rw-r--r-- | .config/zsh/.zshrc | 34 | ||||
-rw-r--r-- | .config/zsh/completion.zsh (renamed from .config/zsh/completions.zsh) | 0 | ||||
-rw-r--r-- | .config/zsh/utils.zsh | 50 |
3 files changed, 52 insertions, 32 deletions
diff --git a/.config/zsh/.zshrc b/.config/zsh/.zshrc index 367794a..1766e57 100644 --- a/.config/zsh/.zshrc +++ b/.config/zsh/.zshrc @@ -13,28 +13,6 @@ export CDPATH=".:$HOME:$HOME/devil:$HOME/src" # just enables a bit nicer life when copy/pasting commands from docs setopt interactive_comments -# colors in various core utils -alias diff='diff --color' - -grep_opts="--color=auto --exclude-dir=.git" -alias grep="grep $grep_opts" -alias egrep="egrep $grep_opts" -alias fgrep="fgrep $grep_opts" -unset grep_opts - -if command -v exa &> /dev/null; then - alias ls='exa' - alias ll='exa --long --header --all' -elif ls --color &> /dev/null; then - # gnu ls - alias ls='ls --color=auto' - alias ll='ls -l --almost-all --no-group --human-readable' -else - # bsd/mac ls - export CLICOLOR='1' - alias ll='ls -hoA' -fi - # dots go up alias -g ...='../..' alias -g ....='../../..' @@ -43,15 +21,6 @@ alias -g .....='../../../..' # aliases alias cls=clear alias config='git --git-dir=$HOME/.dotfiles --work-tree=$HOME' -alias mkdir='mkdir -p' - -if command -v gpg2 &> /dev/null; then - alias gpg='gpg2' -fi - -if [[ "$OSTYPE" == 'cygwin' ]]; then - alias sudo='cygstart --action=runas' -fi # collapse spaces into tabs in-place # spacetotab <FILE> [WIDTH=4] @@ -60,7 +29,8 @@ function spacetotab () { mv "$1.tmp" "$1" } -source $ZDOTDIR/completions.zsh +source $ZDOTDIR/utils.zsh +source $ZDOTDIR/completion.zsh source $ZDOTDIR/history.zsh source $ZDOTDIR/vi-mode.zsh source $ZDOTDIR/prompt.zsh diff --git a/.config/zsh/completions.zsh b/.config/zsh/completion.zsh index bbaacba..bbaacba 100644 --- a/.config/zsh/completions.zsh +++ b/.config/zsh/completion.zsh diff --git a/.config/zsh/utils.zsh b/.config/zsh/utils.zsh new file mode 100644 index 0000000..e368ea0 --- /dev/null +++ b/.config/zsh/utils.zsh @@ -0,0 +1,50 @@ +# utils.zsh +# Replacements for coreutils, color and reasonable defaults for common tools, etc. + +function has () { + command -v "$@" &> /dev/null +} + +# cat +if has bat; then + alias cat='bat --plain --paging=never' +fi +# should consider another alias for --show-all (and --number on base cat) but it's not a good default + +# diff +alias diff='diff --color' + +# grep +grep_opts="--color=auto --exclude-dir=.git" +alias grep="grep $grep_opts" +alias egrep="egrep $grep_opts" +alias fgrep="fgrep $grep_opts" +unset grep_opts + +# ls +if has exa; then + alias ls='exa' + alias ll='exa --long --header --all' +elif ls --color &> /dev/null; then + alias ls='ls --color=auto' + alias ll='ls -l --almost-all --no-group --human-readable' +else + # bsd/mac ls + export CLICOLOR='1' + alias ll='ls -hoA' +fi + +# mkdir +alias mkdir='mkdir -p' + +# gpg +if has gpg2; then + alias gpg='gpg2' +fi + +# cygwin-specific +if [[ "$OSTYPE" == 'cygwin' ]]; then + alias sudo='cygstart --action=runas' +fi + +unfunction has |