dotfiles/.config/zsh/aliases.zsh

135 lines
4.0 KiB
Bash

alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ls="ls --color=auto -v"
alias ll="ls -lh"
alias l="ls -1"
alias la="ls -a"
alias grep="grep --color=auto"
alias zgrep="zgrep --color=auto"
alias hgrep="fc -liD 0 | grep"
alias psgrep="ps aux | grep -v grep | grep"
alias netgrep="ss --all --extended --processes --oneline --numeric | grep"
alias ltail="tail -n 50"
alias lhead="head -n 50"
alias po="popd"
alias d='print ${dirstack}'
alias man="LC_MESSAGES=C man"
alias make="LC_MESSAGES=C make"
alias free="LC_MESSAGES=C free"
if [[ ${VISUAL} == *emacs(client|remote)* ]]; then
local tmp_editor="${VISUAL/ -c/}"
local ec_opts=""
# Workaround for <https://emacs.stackexchange.com/q/63843>.
[[ -z "${DISPLAY}" ]] && ec_opts=" -c"
alias e="${tmp_editor}${ec_opts}"
if [[ "${tmp_editor}" == *emacsremote ]]; then
alias se="${tmp_editor} --sudo"
elif pgrep -f "emacs --daemon" > /dev/null; then
# Edit files as root in the Emacs instance run by the current user.
alias se="$(command -v emacsremote) ${emacsclient_opts} --sudo --local"
fi
else
alias e="${VISUAL}"
alias se="sudo ${VISUAL}"
fi
alias ta="tmux attach -t tastytea || tmux new-session -s tastytea"
alias exifremove='exiftool -all='
local _tmp_config_alias='git --git-dir=${HOME}/.dotfiles --work-tree=${HOME}'
if [[ "${HOST}" != "ventiloplattform" && -f ~/.ssh/noid_dotfiles ]]; then
_tmp_config_alias="GIT_SSH_COMMAND=\"ssh -i ~/.ssh/noid_dotfiles\" ${_tmp_config_alias}"
fi
alias config="${_tmp_config_alias}"
unset _tmp_config_alias
alias edot="GIT_DIR=${HOME}/.dotfiles GIT_WORK_TREE=${HOME} ${VISUAL}"
alias please='sudo'
alias 🥺='sudo'
alias cmake_static='cmake -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" -DBUILD_SHARED_LIBS=OFF -D CMAKE_EXE_LINKER_FLAGS="-static"'
# Ask before removing crontab.
alias crontab='crontab -i'
# Explicitly use lesspipe.
if command -v lesspipe > /dev/null; then
alias lessp='LESSOPEN="|lesspipe %s" less'
elif command -v lesspipe.sh > /dev/null; then
alias lessp='LESSOPEN="|lesspipe.sh %s" less'
fi
# Follow mode does not work with highlight.
alias lessf='LESSOPEN="" less +F'
alias cp='cp --reflink=auto --preserve=all'
alias mv='nocorrect mv'
alias mkdir='nocorrect mkdir'
alias cat='cat-highlight'
alias ip='ip -color -brief'
# Add --accept=".jpg,.png" or whatever.
alias wget_leech='wget --no-directories --page-requisites --span-hosts'
alias diff='diff --color=auto'
alias alert='print -n "\a"'
# deprecated
alias machklein='mksmol'
# OS specific settings.
if [[ -f /etc/gentoo-release ]]; then
# Directory aliases for some Gentoo paths
for dir in /etc/portage/package.*; do
hash -d -- -${dir##*/}=${dir}
done
# Directory aliases for all enabled repos
function _my_diralias_repo_done()
{
local return_code=${2}
local stdout=${3}
if [[ ${return_code} -eq 0 ]]; then
if [[ "${stdout%%=*}" == "allrepos" ]]; then
# We got the list of repos
for repo in $(print ${stdout#*=}); do
async_job diralias_repo _my_diralias_repo ${repo}
done
else
# We got the path of a repo
local repo="repo_${stdout%%=*}"
hash -d -- -${repo}="${stdout#*=}"
fi
fi
}
function _my_diralias_repo()
{
print -n "${1}="
nice portageq get_repo_path / "${1}"
}
async_start_worker diralias_repo
async_register_callback diralias_repo _my_diralias_repo_done
async_job diralias_repo 'print -n "allrepos=$(portageq get_repos /)"'
fi
command -v apt-cache > /dev/null && alias qs="apt-cache search --names-only"
# Directory aliases for Gentoo repos in my home dir
for repo in gentoo guru; do
[[ -d ~/Projekte/${repo} ]] && hash -d -- -devrepo_${repo}=~/Projekte/${repo}
done
if [[ -d ~/Projekte/overlay-tastytea ]]; then
hash -d -- -devrepo_tastytea=~/Projekte/overlay-tastytea
fi