#!/usr/bin/env bash # Color the grep output alias grep="grep --color" x-have eza && { alias ls="eza -h -s=type --git --icons --group-directories-first" } alias vim='vim -u "$XDG_CONFIG_HOME/vim/vimrc"' # Easier navigation: .., ..., .... alias ..="cd .." alias ...="cd ../.." alias ....="cd ../../.." # Get git repository root path get_git_root() { # check that we are in a git repository if git rev-parse --is-inside-work-tree &> /dev/null; then git rev-parse --show-toplevel else >&2 msgr err "Not in a git repository" fi } # cd to git root directory alias cdgr='cd "$(get_git_root)"' # interesting folders, and shortcuts alias .='cd $HOME' alias .b='cd $XDG_BIN_HOME' alias .c='cd $HOME/Code' alias .d='cd $DOTFILES' alias .l='cd $HOME/.local' alias .o='cd $HOME/Code/ivuorinen/obsidian/' # Shortcuts for listing alias ll="ls -la" alias l="ls -a" # Prevent common typos alias cd..="cd .." alias sl="ls" # IP addresses alias x-ip="dig +short myip.opendns.com @resolver1.opendns.com" alias localip="ipconfig getifaddr en1" alias ips="ifconfig -a | grep -o 'inet6\? \(\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+\)\|[a-fA-F0-9:]\+\)' | sed -e 's/inet6* //' | sort" # Show/hide hidden files in Finder alias show="defaults write com.apple.finder AppleShowAllFiles -bool true; killall Finder" alias hide="defaults write com.apple.finder AppleShowAllFiles -bool false; killall Finder" # Pipe public key to clipboard. alias pubkey="more ~/.ssh/id_rsa.pub | pbcopy | echo '=> Public key copied to pasteboard.'" # Flush Directory Service cache alias flush="dscacheutil -flushcache" # Update locatedb alias updatedb="sudo /usr/libexec/locate.updatedb" # Date helpers alias isodate="date +'%Y-%m-%d'" alias x-datetime="date +'%Y-%m-%d %H:%M:%S'" alias x-timestamp="date +'%s'" # nvim aliases alias vi='nvim' alias vim='nvim' # xdg-ninja aliases for better experience alias xdg='xdg-ninja --skip-ok --skip-unsupported' # watch with: differences, precise, beep and color alias watchx='watch -dpbc' # delete .DS_Store files alias zapds='find . -name ".DS_Store" -print -delete' # Recursively delete `.pyc` files alias zappyc="find . -type f -name '*.pyc' -ls -delete" # Run all zaps alias zapall="zapds && zappyc" # directory usage, return only the total alias dn='du -chd1' # Mirror site with wget alias mirror_site='wget -m -k -K -E -e robots=off' # Mirror stdout to stderr, useful for seeing data going through a pipe alias peek='tee >(cat 1>&2)' # Runs Gitlab code quality scanner alias code_scanner='docker run --env SOURCE_CODE="$PWD" --volume "${PWD}":/code --volume /var/run/docker.sock:/var/run/docker.sock registry.gitlab.com/gitlab-org/ci-cd/codequality:"${CODEQUALITY_VERSION:-latest}" /code' # Runs trivy container image scanner alias trivy_scan='docker run -v /var/run/docker.sock:/var/run/docker.sock -v $HOME/Library/Caches:/root/.cache/ aquasec/trivy' # Opens dotfiles with $EDITOR alias zedit='$EDITOR ~/.dotfiles' # Open irssi with my configurations alias irssi='irssi --config=$XDG_CONFIG_HOME/irssi/config --home=$XDG_CONFIG_HOME/irssi' # Configures wget to use correct wget-hsts file alias wget='wget --hsts-file=$XDG_DATA_HOME/wget-hsts' # Configures svn to use correct config directory alias svn='svn --config-dir $XDG_CONFIG_HOME/subversion' # Laravel artisan shortcut alias art='[ -f artisan ] && php artisan || php vendor/bin/artisan' # Laravel Sail shortcut alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail' if [[ $(uname) == 'Darwin' ]]; then # Flush Directory Service cache alias flushdns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder" # Lock the screen alias afk="osascript -e 'tell application \"System Events\" to keystroke \"q\" using {command down,control down}'" # Empty the Trash on all mounted volumes and the main HDD # Also, clear Apple's System Logs to improve shell startup speed alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl" # Using herd for php now, so this is not needed anymore # x-set-php-aliases fi X_ALIAS_FILES=( "$HOME/.config/alias-secret" "$HOME/.config/alias-$(hostname)" "$HOME/.config/alias-$(hostname)-secret" ) for aliasFile in "${X_ALIAS_FILES[@]}"; do # shellcheck source=$HOME/.config/alias-secret [ -f "$aliasFile" ] && source "$aliasFile" && msgr ok "Sourced $aliasFile" done unset X_ALIAS_FILES