Skip to content

Instantly share code, notes, and snippets.

@CyberPunkCodes
Last active April 15, 2023 16:48
Show Gist options
  • Save CyberPunkCodes/bd873db7cd9051f2c0d231f3f7f3e0a8 to your computer and use it in GitHub Desktop.
Save CyberPunkCodes/bd873db7cd9051f2c0d231f3f7f3e0a8 to your computer and use it in GitHub Desktop.
Oh-My-Zsh - Best and Most Helpful - My Custom ZSH Aliases - Tips Hack Help Info Doc Tutorial
# Source Reload
alias reload.zsh="source ~/.zshrc"
alias reload.profile="source ~/.bash_profile"
alias reload.term="source ~/.bash_profile && source ~/.zshrc"
# cd
alias ..="cd .."
# ls
alias ll="ls -AlhG"
#alias cll="/usr/local/bin/cll `pwd`"
# tar
alias tarr="tar -pczf $1 $2"
alias untarr="tar -pxzf $1"
alias starr="sudo tar -pczf $1 $2"
# Paths
alias go.webroot="/Applications/XAMPP/xamppfiles/htdocs"
alias go.sites="~/Sites"
# Mac
alias mac.showhidden="defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder"
alias mac.hidehidden="defaults write com.apple.finder AppleShowAllFiles FALSE && killall Finder"
# Docker
alias docker.cleancontainer="docker ps -a -q | xargs docker rm"
alias docker.cleanimage="docker images --filter dangling=true -q | xargs docker rmi"
# Find & Delete all ".DS_Store" files (recursive)
alias delete.ds="find . -name '.DS_Store' -type f -print -delete"
# Functions - My perfected ls command!
cll() { ls -AlhG "$@" | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(" %0o ",k);print}' | cut -c 1-5,21-; }
@CyberPunkCodes
Copy link
Author

Introduction

This is my current custom aliases.zsh file for Oh-My-Zsh.

You are not supposed to edit your .zshrc file! It is only for the main settings. If you want to add custom things (like aliases, functions, etc), then you should create a new file.zsh in /Users/<you>/.oh-my-zsh/custom/. I chose to name it aliases.zsh as majority of them are aliases. You can create multiple files, they all should be loaded. So you could create aliases.zshfor aliases and functions.zsh for your functions, and whatever else you want.

Installation:

NOTE: You must have Oh-My-Zsh installed. Replace <you> in the path below with your username.

First, cd into your Oh-My-Zsh custom directory:
cd /Users//.oh-my-zsh/custom

Then use one of the below methods to download this gist:

Curl Method

curl -o aliases.zsh https://gist.githubusercontent.com/WadeShuler/bd873db7cd9051f2c0d231f3f7f3e0a8/raw/6f03fda43ff40cae99c134138415352a14960173/aliases.zsh

Wget Method

wget https://gist.githubusercontent.com/WadeShuler/bd873db7cd9051f2c0d231f3f7f3e0a8/raw/6f03fda43ff40cae99c134138415352a14960173/aliases.zsh

PHP Method

php -r "copy('https://gist.githubusercontent.com/WadeShuler/bd873db7cd9051f2c0d231f3f7f3e0a8/raw/6f03fda43ff40cae99c134138415352a14960173/aliases.zsh', 'aliases.zsh');"

Copy-n-Paste method

touch aliases.zsh && nano aliases.zsh

Copy the raw code from here and paste it into your Terminal.

CTRL+o (Oh, not zero) Then EnterTo save
CTRL+x To exit


I hope you find my custom Oh-My-Zsh aliases helpful!

Did You Know

Did you know that you can use dots/periods in your alias names? I used a few in my Gist above. It makes remembering them easier, and allows you to group them.

For example, for all my paths that I may want quick access to, they start with go. So I can do:

go.webroot
go.home
go.downloads
go.desktop

Now, I don't have all of those defined in my Gist, so they won't work. Just showing how the (dot) can group your similar commands together. Maybe you wanted to define some Git aliases. You could do:

git.pull
git.fetch
git.update
git.init

Contributing

Do you have a function that is awesome and majority of people would probably find useful? Feel free to let me know. If I like it, it may find it's way into this Gist 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment