Skip to content

Instantly share code, notes, and snippets.

@aortiz49
Created February 10, 2020 01:15
Show Gist options
  • Save aortiz49/425cba3dc652baae5242b4f88562e7aa to your computer and use it in GitHub Desktop.
Save aortiz49/425cba3dc652baae5242b4f88562e7aa to your computer and use it in GitHub Desktop.
#####################################################
# █████╗ ██╗ ██╗ █████╗ ███████╗███████╗███████╗
# ██╔══██╗██║ ██║██╔══██╗██╔════╝██╔════╝██╔════╝
# ███████║██║ ██║███████║███████╗█████╗ ███████╗
# ██╔══██║██║ ██║██╔══██║╚════██║██╔══╝ ╚════██║
# ██║ ██║███████╗██║██║ ██║███████║███████╗███████║
# ╚═╝ ╚═╝╚══════╝╚═╝╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝
# renegade - Andy Ortiz
#####################################################
###################### ZSH ######################
alias reload=". ~/.zshrc"
alias edit="code $ZSH_CUSTOM/aliases.zsh -a"
alias zshrc="code $ZSH_HOME"
###################### Git ######################
# Initialzies an empty Git repository
function gi(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git init \e[39m"
git init
}
# Shows the working tree status
function gs(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git status \e[39m"
git status
}
# Shows the currently staged files
function gls(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git ls-files \e[39m"
git ls-files
}
# Adds a file to the staging area
function ga(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git add \e[93m$1\e[39m"
git add $1
}
# Pushes local commits to the remote repository
function gp(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git push \e[39m"
git push
}
# Commits changes to added files and leaves a commit message
function gcm(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git commit -m \e[93m$1 \e[39m"
git commit -m $1
}
# Creates a branch and checks it out
function gcb(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git checkout -b \e[93m$1 \e[39m"
git checkout -b $1
}
# Checks out a branch
function gch(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git checkout \e[93m$1 \e[39m"
git checkout $1
}
# Merges the current branch with the brancg given by parameter
function gm(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git merge \e[93m$1 \e[39m"
git merge $1
}
# Downloads commits etc from a remote repo to local repo (doesn't force merge)
function gfa(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git fetch --all \e[93m$1 \e[39m"
git fetch --all
}
# Downloads commits etc from a remote repo to local repo and merges (git fetch + git merge)
function gpa(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git pull --all \e[93m$1 \e[39m"
git pull --all
}
# Prints a tree of commits and branches
function gitlg(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git log --graph --oneline --decorate --date=relative --all \e[39m"
git log --graph --oneline --decorate --date=relative --all
}
# Resets git branch
function gitrst(){
echo -e "\e[1m\e[94m➜\e[0m\e[95m git reset --hard origin/master \e[39m"
git reset --hard origin/master
}
# Creates the git remote for a repo
function grem() {
local a
a="\e[1m\e[32m➜ \e[95mgit remote add origin "
local b
b="\e[32mgit@github.com:aortiz49/\e[96m$1\e[91m.git"
echo -e $a$b
git remote add origin git@github.com:aortiz49/"$1".git
}
# Sets the upsteam of a new branch to push
function gpo() {
git push --set-upstream origin "$1"
}
#################################################
################## Directories ##################
#################################################
# Clears the screen
function cl() {
print '\33c\e[3J'
}
# Enters the university directory
function cdu(){
echo -e "\e[1m\e[32m➜ \e[95mcd Uniandes/Sem\ 4/"
cd Uniandes/Sem\ 4/
}
alias cddocs-="cd ~/Documents/"
alias del="rm -rf"
# Creates a new folder and opens it
new () {
mkdir "$1"
cd "$1"
}
# Compile C code
alias c="gcc –o"
# Big clear command that resets the shell and empties the screen
alias bc="clear && printf '\e[3J' && exec zsh"
## Help for some commands
#rename 's/<expression>/<replacement>/' * -n (expressions support regEX)
# for n ({0..10})
# type code here
# for f (**/*.zsh) {echo $f}
# this prints all filenames matching .zsh extension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment