Last active
August 10, 2022 07:46
-
-
Save mokhosh/0f08be60df72e8156a67cc27623d0cf5 to your computer and use it in GitHub Desktop.
zsh aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias cp='cp -iv' # Preferred 'cp' implementation | |
alias mv='mv -iv' # Preferred 'mv' implementation | |
alias mkdir='mkdir -pv' # Preferred 'mkdir' implementation | |
cd() { builtin cd "$@"; ll; } # Always list directory contents upon 'cd' | |
alias cd..='cd ../' # Go back 1 directory level (for fast typers) | |
alias ..='cd ../' # Go back 1 directory level | |
alias ...='cd ../../' # Go back 2 directory levels | |
alias .3='cd ../../../' # Go back 3 directory levels | |
alias .4='cd ../../../../' # Go back 4 directory levels | |
alias .5='cd ../../../../../' # Go back 5 directory levels | |
alias .6='cd ../../../../../../' # Go back 6 directory levels | |
alias edit='code' # edit: Opens any file in sublime editor | |
alias f='open -a Finder ./' # f: Opens current directory in MacOS Finder | |
alias ~="cd ~" # ~: Go Home | |
alias c='clear' # c: Clear terminal display | |
alias which='type -all' # which: Find executables | |
alias path='echo -e ${PATH//:/\\n}' # path: Echo all executable Paths | |
mcd () { mkdir -p "$1" && cd "$1"; } # mcd: Makes new Dir and jumps inside | |
# ls stuff, most are set in lib/directories.zsh | |
# I use lsd (https://github.com/Peltoche/lsd) for certain listings | |
alias ls='ls -G' | |
alias l='lsd -l' | |
alias la='lsd -la' | |
alias lt='ls -ltFho' #long list,sorted by date,show type,human readable | |
alias ldot='ls -ld .*' #list dot files | |
alias ll='ls -la -FGash' | |
# CD Shortcuts | |
alias sites="cd ~/Sites" | |
alias dev="cd ~/dev" | |
alias omz="cd ~/.oh-my-zsh" | |
alias omzc="cd ~/.oh-my-zsh/custom" | |
# Quick edit to my aliases and zshrc config | |
alias zshrc="nano ~/.zshrc" | |
alias aliases='nano ~/.aliases' | |
alias caliases="nano ~/.oh-my-zsh/custom/myaliases.zsh" | |
alias galiases="cat ~/.oh-my-zsh/plugins/git/git.plugin.zsh | grep alias" | |
alias bashprofile='nano ~/.bash_profile' | |
alias hosts='nano /etc/hosts' | |
# Git | |
alias gac="git add . && git commit -m" | |
alias ga="git add" | |
alias gc="git commit -m" | |
alias gs="git status" | |
alias gl="git log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)%Creset' --abbrev-commit --branches" | |
alias diff="git diff" | |
alias nah="git reset --hard && git clean -df" | |
alias amend="git add . && git commit --amend" | |
alias g='git' | |
alias gss='git status -s' | |
alias gd='git diff' | |
alias gll='git log --graph --pretty=oneline --abbrev-commit' | |
alias gg="git log --graph --pretty=format:'%C(bold)%h%Creset%C(magenta)%d%Creset %s %C(yellow)<%an> %C(cyan)(%cr)%Creset' --abbrev-commit --date=relative" | |
alias glg='git log --graph --oneline --decorate --all' | |
alias gld='git log --pretty=format:"%h %ad %s" --date=short --all' | |
alias gsl="git shortlog -sn" | |
alias gwc="git whatchanged" | |
# Git log find by commit message | |
function glf() { git log --all --grep="$1"; } | |
# Lists | |
alias mkdir='mkdir -pv' | |
# Enable aliases to be sudo'ed | |
alias sudo='sudo ' | |
# Get macOS Software Updates, and update installed composer packages, Homebrew, npm, and their installed packages | |
alias update='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; npm install npm -g; npm update -g; composer -g update;' | |
# Google Chrome | |
alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome' | |
# IP addresses | |
alias ip="dig +short myip.opendns.com @resolver1.opendns.com" | |
alias localip="ipconfig getifaddr en0" | |
alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'" | |
# Show active network interfaces | |
alias ifactive="ifconfig | pcregrep -M -o '^[^\t:]+:([^\n]|\n\t)*status: active'" | |
# Recursively delete `.DS_Store` files | |
alias cleanup="find . -type f -name '*.DS_Store' -ls -delete" | |
# Hide/show all desktop icons (useful when presenting) | |
alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder" | |
alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder" | |
# Print each PATH entry on a separate line | |
alias path='echo -e ${PATH//:/\\n}' | |
# showa: to remind yourself of an alias (given some part of it) | |
# ------------------------------------------------------------ | |
showa () { /usr/bin/grep --color=always -i -a1 $@ ~/Library/init/bash/aliases.bash | grep -v '^\s*$' | less -FSRXc ; } | |
# lr: Full Recursive Directory Listing | |
# ------------------------------------------ | |
alias lr='ls -R | grep ":$" | sed -e '\''s/:$//'\'' -e '\''s/[^-][^\/]*\//--/g'\'' -e '\''s/^/ /'\'' -e '\''s/-/|/'\'' | less' | |
# Laravel | |
alias art="php artisan" | |
alias tinker="art tinker" | |
# Flutter | |
alias apk="flutter build apk --target-platform android-arm && open build/app/outputs/apk/release/" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment