### Common aliases alias dir="ls -a" alias l="ls -la" if (( $+commands[eza] )); then alias ls2='eza --group-directories-first --icons' alias dir2='ls2 -a' alias la2='ls2 -a' alias ll2='ls2 -l --group' alias tree2='ls2 --tree' fi alias cls="clear" alias cw="clear; w" alias x="exit" alias tree="\tree -C --dirsfirst" alias bc="bc -ql" alias tt=traceroute alias ports="sudo netstat -luntp" alias myip="curl -s icanhazip.com" alias weather='curl wttr.in/kyiv' alias batcat="bat" alias h='fc -li' alias hg='fc -li | grep' alias va='source ./venv/bin/activate' alias ve='python3 -m venv ./venv' alias list_instances="aws ec2 describe-instances --no-cli-pager --color off --filters Name=tag-key,Values=Name Name=instance-state-name,Values=running --query 'Reservations[*].Instances[*].{Instance_Id:InstanceId,Type:InstanceType,Public_IP:PublicIpAddress,Private_IP:PrivateIpAddress,SSH_Key:KeyName,Name:Tags[?Key==\`Name\`]|[0].Value}' --output table" # Find top 5 big files alias findbig="find . -type f -exec ls -s {} \; | sort -n -r | head -5" # To clear all the history and screen alias hcl='history -c; clear' # Make basic commands verbose alias cp="cp -v" alias rm="rm -v" alias mv="mv -v" # To navigate to the different directories alias ..='cd ..' alias ...='cd ../..' # Create and change to a new directory mcd() { if [[ -z "$1" ]]; then echo "Usage: mcd " return 1 fi mkdir -p "$1" && cd "$1" } # display currently mounted file systems nicely showmounted() { (echo "DEVICE PATH TYPE FLAGS" && mount | awk '$2=$4="";1') | column -t; } # Local aliases alias gfo="git fetch origin && git status" alias zimdate="LC_TIME=en_US.UTF-8 date '+Week %V%n%A, %d.%m.%Y'" if (( $+commands[apg] )); then alias apg1="apg -a 0 -n 1 -m 8 -x 10 -M NCL -E I1l0O" alias apg2="apg -a 0 -n 1 -m 14 -x 16 -M NCL -E I1l0O" alias apg3="apg -a 0 -n 1 -m 14 -x 16 -M NCLS -E I1l0O" fi ######################################################################################### ### OS-specific case "$(uname)" in Darwin) # Configuration if Brew installed () { local bp="" [[ -x /opt/homebrew/bin/brew ]] && bp="/opt/homebrew" [[ -x /usr/local/bin/brew ]] && bp="/usr/local" if [[ -n "$bp" ]]; then export HOMEBREW_AUTO_UPDATE_SECS=86400 export HOMEBREW_NO_ANALYTICS=1 if (( $+commands[gls] )); then # Using local variable for aliases alias ls="$bp/bin/gls --color=never -F --group-directories-first" alias date="$bp/bin/gdate" alias findbig="gfind . -type f -printf '%s %p\n' | sort -rn | head -5" else [[ -t 1 ]] && echo "\e[33mNotice:\e[0m Coreutils not found. Run: brew install coreutils" fi fi } alias openfinder='open -a Finder $1' alias flushdns='sudo dscacheutil -flushcache' alias cleanup="find . -type f -name '*.DS_Store' -ls -delete" # This alias will find and delete all ".DS_Store" files in the current directory and all subdirectories. alias battery="pmset -g batt | grep -Eo '[0-9]+%' | sed 's/%//'" alias play_alert='afplay ~/Sync/music/effects/Train\ Fx\ 2.wav' alias update='~/scripts/update_macos.sh' alias showfiles='defaults write com.apple.finder AppleShowAllFiles YES && killall Finder' alias hidefiles='defaults write com.apple.finder AppleShowAllFiles NO && killall Finder' alias localip='ipconfig getifaddr en0' ;; Linux) alias ls='/bin/ls --color=never -F --group-directories-first' alias bat='/usr/bin/batcat' alias monitor_turn_off='xset dpms force off' alias play_alert='aplay ~/Sync/music/effects/Train\ Fx\ 2.wav' alias psc='ps xawf -eo pid,user,cgroup,args' alias pss='systemd-cgls' alias update='~/scripts/update.sh' alias update_download_only='sudo apt update && sudo apt upgrade --download-only --assume-yes' alias update_small='sudo apt upgrade --assume-yes' alias pbcopy="$HOME/scripts/stub_pbcopy.sh" alias findbig="find . -type f -exec ls -s {} \; | sort -n -r | head -5" ;; esac # Pictures (ZSH suffixes) if [[ "$TERM_PROGRAM" == "WezTerm" ]]; then alias icat="wezterm imgcat" elif [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then alias icat="imgcat" elif [[ "$TERM" == *"konsole"* ]]; then alias icat="img2sixel" else alias icat="open" fi alias -s png="icat" alias -s jpg="icat" alias -s jpeg="icat" alias -s gif="icat" alias -s bmp="icat" alias -s webp="icat" alias -s ico="icat" # preview all images in current directory icatdir() { for img in *.{png,jpg,jpeg,gif,webp,bmp}(N); do echo "--- $img ---" icat "$img" done }