1
0
Fork 0
dotfiles/.config/zsh/aliases.zsh

138 lines
3.9 KiB
Bash
Raw Normal View History

2022-03-18 14:34:27 +01:00
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"
2022-03-24 01:24:45 +01:00
alias hgrep="fc -liD 0 | grep"
2022-03-18 14:34:27 +01:00
alias psgrep="ps aux | grep -v grep | grep"
2022-04-18 20:04:06 +02:00
alias netgrep="ss --all --extended --processes --oneline --numeric | grep"
2022-03-18 14:34:27 +01:00
alias ltail="tail -n 50"
alias lhead="head -n 50"
alias po="popd"
2022-03-28 06:14:46 +02:00
alias d='print ${dirstack}'
2022-03-18 14:34:27 +01:00
alias man="LC_MESSAGES=C man"
alias make="LC_MESSAGES=C make"
alias free="LC_MESSAGES=C free"
2024-01-04 23:09:27 +01:00
local sucmd=sudo
if type doas >& -; then
sucmd=doas
fi
alias please=${sucmd}
alias 🥺=${sucmd}
2022-04-28 12:53:35 +02:00
if [[ ${VISUAL} == *emacs(client|remote)* ]]; then
2022-03-18 14:34:27 +01:00
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}"
2022-04-28 12:53:35 +02:00
if [[ "${tmp_editor}" == *emacsremote ]]; then
2022-03-18 14:34:27 +01:00
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}"
2024-01-04 23:09:27 +01:00
alias se="${sucmd} ${VISUAL}"
2022-03-18 14:34:27 +01:00
fi
alias ta="tmux attach -t tastytea || tmux new-session -s tastytea"
alias exifremove='exiftool -all='
alias config='git --git-dir=${HOME}/.dotfiles --work-tree=${HOME}'
2022-08-20 23:13:21 +02:00
alias edot="GIT_DIR=${HOME}/.dotfiles GIT_WORK_TREE=${HOME} ${VISUAL}"
2022-03-18 14:34:27 +01:00
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.
2022-03-22 22:43:16 +01:00
if command -v lesspipe > /dev/null; then
2022-03-18 14:34:27 +01:00
alias lessp='LESSOPEN="|lesspipe %s" less'
2022-03-22 22:43:16 +01:00
elif command -v lesspipe.sh > /dev/null; then
alias lessp='LESSOPEN="|lesspipe.sh %s" less'
2022-03-18 14:34:27 +01:00
fi
# Follow mode does not work with highlight.
alias lessf='LESSOPEN="" less +F'
alias cp='cp --reflink=auto --preserve=all'
2022-04-28 13:00:58 +02:00
alias mv='nocorrect mv'
2022-06-04 21:27:27 +02:00
alias mkdir='nocorrect mkdir'
2022-07-17 01:32:20 +02:00
alias cat='cat-highlight'
2022-03-18 14:34:27 +01:00
alias ip='ip -color -brief'
# Add --accept=".jpg,.png" or whatever.
alias wget_leech='wget --no-directories --page-requisites --span-hosts'
2022-03-28 03:56:52 +02:00
alias diff='diff --color=auto'
2022-07-17 01:32:20 +02:00
alias alert='print -n "\a"'
# deprecated
alias machklein='mksmol'
2024-03-12 11:35:07 +01:00
# kitty
if [[ ${TERMINAL} == "kitty" ]]; then
alias icat='kitten icat'
fi
2022-03-18 14:34:27 +01:00
# 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}="
2022-04-08 00:39:53 +02:00
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
2022-03-18 14:34:27 +01:00
2022-03-28 03:56:52 +02:00
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}
2022-03-18 14:34:27 +01:00
done
if [[ -d ~/Projekte/overlay-tastytea ]]; then
hash -d -- -devrepo_tastytea=~/Projekte/overlay-tastytea
fi