zsh:alias: Move add_flags section to the bottom
This way the commands can get aliased in other ways first and then get their flags added.
This commit is contained in:
@@ -1,18 +1,6 @@
|
|||||||
## Author: druckdev
|
## Author: druckdev
|
||||||
## Created: 2019-01-16
|
## Created: 2019-01-16
|
||||||
|
|
||||||
# Helper functions for this file. Are `unfunction`ed at the end.
|
|
||||||
is_exec() {
|
|
||||||
(( $# > 0 )) || return 1
|
|
||||||
(( $+commands[$1] || $+aliases[$1] || $+functions[$1] ))
|
|
||||||
}
|
|
||||||
|
|
||||||
add_flags() {
|
|
||||||
(( $# >= 2 )) || (( $+commands[$1])) || return 0
|
|
||||||
|
|
||||||
alias "$1"="${aliases[$1]:-$1} ${*[2,-1]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Create aliases for coreutils versions of commands under OSX.
|
# Create aliases for coreutils versions of commands under OSX.
|
||||||
# NOTE: This should come before any other alias definitions of these commands as
|
# NOTE: This should come before any other alias definitions of these commands as
|
||||||
# otherwise this block would overwrite them.
|
# otherwise this block would overwrite them.
|
||||||
@@ -26,30 +14,6 @@ if [[ $OSTYPE =~ darwin && -e /usr/local/Cellar/coreutils ]]; then
|
|||||||
unset f no_gnu_file
|
unset f no_gnu_file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Default flags
|
|
||||||
(( ! $+functions[ls-show-hidden] )) ||
|
|
||||||
alias ls='ls-show-hidden --color=auto --group-directories-first -p -v'
|
|
||||||
add_flags grep --color=auto --exclude-dir=.git --exclude=tags
|
|
||||||
add_flags cp -i
|
|
||||||
add_flags mv -i
|
|
||||||
add_flags rm -I
|
|
||||||
add_flags mkdir -p
|
|
||||||
add_flags lsblk -o NAME,LABEL,FSTYPE,SIZE,FSAVAIL,MOUNTPOINT
|
|
||||||
add_flags feh --scale-down --image-bg "'#898e8c'"
|
|
||||||
# Use multiple jobs when making
|
|
||||||
add_flags make -j
|
|
||||||
# Bulk renaming with (almost) all files and directly modifying the
|
|
||||||
# destination.
|
|
||||||
add_flags qmv -Af destination-only
|
|
||||||
# Match against and list full command line
|
|
||||||
add_flags pgrep --full --list-full
|
|
||||||
|
|
||||||
# XDG Base Directory Specification
|
|
||||||
add_flags tmux -f "${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
|
|
||||||
add_flags yarn --use-yarnrc "${XDG_CONFIG_HOME:-$HOME/.config}"/yarn/config
|
|
||||||
add_flags bash --rcfile "${XDG_CONFIG_HOME:-$HOME/.config}"/bash/bashrc
|
|
||||||
add_flags mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc
|
|
||||||
|
|
||||||
# Global
|
# Global
|
||||||
alias -g G='| grep'
|
alias -g G='| grep'
|
||||||
alias -g no1='>/dev/null'
|
alias -g no1='>/dev/null'
|
||||||
@@ -115,6 +79,7 @@ fi
|
|||||||
unset SETCLIP_PREFIX
|
unset SETCLIP_PREFIX
|
||||||
|
|
||||||
# Save keystrokes and my memory
|
# Save keystrokes and my memory
|
||||||
|
(( ! $+functions[ls-show-hidden] )) || alias ls='ls-show-hidden'
|
||||||
alias la='ls -A'
|
alias la='ls -A'
|
||||||
alias l='ls -lh --time-style=long-iso'
|
alias l='ls -lh --time-style=long-iso'
|
||||||
alias ll='l -A'
|
alias ll='l -A'
|
||||||
@@ -169,6 +134,18 @@ fi
|
|||||||
# Count number of occurrences for every line in stdin
|
# Count number of occurrences for every line in stdin
|
||||||
alias count='sort | uniq -c | sort -n'
|
alias count='sort | uniq -c | sort -n'
|
||||||
|
|
||||||
|
# Helper functions for this file. Are `unfunction`ed at the end.
|
||||||
|
is_exec() {
|
||||||
|
(( $# > 0 )) || return 1
|
||||||
|
(( $+commands[$1] || $+aliases[$1] || $+functions[$1] ))
|
||||||
|
}
|
||||||
|
|
||||||
|
add_flags() {
|
||||||
|
(( $# >= 2 )) || (( $+commands[$1])) || return 0
|
||||||
|
|
||||||
|
alias "$1"="${aliases[$1]:-$1} ${*[2,-1]}"
|
||||||
|
}
|
||||||
|
|
||||||
# External command depending aliases
|
# External command depending aliases
|
||||||
(( ! $+commands[zathura] )) ||
|
(( ! $+commands[zathura] )) ||
|
||||||
alias pdf='zathura --fork &>/dev/null'
|
alias pdf='zathura --fork &>/dev/null'
|
||||||
@@ -191,4 +168,27 @@ fi
|
|||||||
! is_exec vi ||
|
! is_exec vi ||
|
||||||
alias v='vi'
|
alias v='vi'
|
||||||
|
|
||||||
|
# Default flags
|
||||||
|
add_flags ls --color=auto --group-directories-first -p -v
|
||||||
|
add_flags grep --color=auto --exclude-dir=.git --exclude=tags
|
||||||
|
add_flags cp -i
|
||||||
|
add_flags mv -i
|
||||||
|
add_flags rm -I
|
||||||
|
add_flags mkdir -p
|
||||||
|
add_flags lsblk -o NAME,LABEL,FSTYPE,SIZE,FSAVAIL,MOUNTPOINT
|
||||||
|
add_flags feh --scale-down --image-bg "'#898e8c'"
|
||||||
|
# Use multiple jobs when making
|
||||||
|
add_flags make -j
|
||||||
|
# Bulk renaming with (almost) all files and directly modifying the
|
||||||
|
# destination.
|
||||||
|
add_flags qmv -Af destination-only
|
||||||
|
# Match against and list full command line
|
||||||
|
add_flags pgrep --full --list-full
|
||||||
|
|
||||||
|
# XDG Base Directory Specification
|
||||||
|
add_flags tmux -f "${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
|
||||||
|
add_flags yarn --use-yarnrc "${XDG_CONFIG_HOME:-$HOME/.config}"/yarn/config
|
||||||
|
add_flags bash --rcfile "${XDG_CONFIG_HOME:-$HOME/.config}"/bash/bashrc
|
||||||
|
add_flags mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc
|
||||||
|
|
||||||
unfunction add_flags is_exec
|
unfunction add_flags is_exec
|
||||||
|
|||||||
Reference in New Issue
Block a user