Skip to content

Instantly share code, notes, and snippets.

@icodeyou
Created March 5, 2026 09:31
Show Gist options
  • Select an option

  • Save icodeyou/393be1c94e45f375c27129297a7c125d to your computer and use it in GitHub Desktop.

Select an option

Save icodeyou/393be1c94e45f375c27129297a7c125d to your computer and use it in GitHub Desktop.
Alias Paradise
# Clean conflicted files
alias cc="find . -type f -name '*\[conflicted*' -delete" # clean conflicted
# Brew
export HOMEBREW_AUTO_UPDATE_SECS=30000
alias bbi='!HOMEBREW_NO_AUTO_UPDATE=1 brew install'
# Dev notes
alias devnotes='cd ~/dev/devnotes'
alias setup='devnotes; cd setup'
alias files='devnotes; cd setup/files'
alias is='devnotes; n setup/INFOS_SETUP.txt'
alias scripts='devnotes; cd scripts'
# cd general
alias a='n ~/.oh-my-zsh/custom/my_aliases.zsh' # Aliases for ZSH
alias aa='source ~/.zshrc'
alias u='devnotes; gs; echo "-------------------------------"; echo "Press enter to commit and push GENERAL edits"; cf; gca "quickly update devnotes/"; gp'
alias ua='devnotes; gs; echo "-------------------------------"; echo "Press enter to commit and push ALIAS edits"; cf; gca "quickly update aliases"; gp'
alias ui='devnotes; gs; echo "-------------------------------"; echo "Press enter to commit and push INFOS_SETUP edits"; cf; gaa; gca "quickly update INFOS_SETUP notes"; gp'
alias uo='devnotes; gs; echo "-------------------------------"; echo "Press enter to commit and push OBSIDIAN edits"; cf; gaa; gca "quickly update obsidian notes"; gp'
alias uv='devnotes; gs; echo "-------------------------------"; echo "Press enter to commit and push VS CODE edits"; cf; gaa; gca "quickly update VS-Code notes"; gp'
alias ccat='pygmentize -g'
alias cdtrash='cd ~/.Trash'
alias cdt='cdtrash'
alias temp='cd ~/dev/temp'
alias custom='cd ~/.oh-my-zsh/custom'
alias cdz='cd $ZSH_CUSTOM'
alias config='n ~/.oh-my-zsh/custom/config.zsh'
alias bc='n ~/.bashrc' # unnecessary with ZSH
alias bp='n ~/.bash_profile' # unnecessary with ZSH
alias zc='n ~/.zshrc'
alias music='cd ~/Music/Logic'
alias dtc='cd ~/Music/Logic/DTC'
alias mw='cd ~/Music/Logic/MY_WORK'
# Essential - Needs to be defined before functions
alias ktlint='ktlint --color'
cf() { # "cf" stands for confirm
echo "⚠️ Continue ?"
read answer
# Don't try to kill process manually ... You will waste your time.
# "Ctrl + C" is good enough, trust me.
}
cfs() { # "cfs" stands for confirm silently
read answer
}
# ça prend du temps de checker les tests, donc on ne vérifie pas //nocommit dans les tests
alias checknocommit='if grep -qirs nocommit lib/ cdapp/lib/ cdapp_theme/lib/; then echo ALERTE ROUGE !!! Your code contains \"nocommit\" somewhere.. ; cf; fi'
alias checknopush='if grep -qirs nopush lib/ test/ cdapp/lib/ cdapp/test/ cdapp_theme/lib/ cdapp_theme/test/; then echo ALERTE ROUGE !!! Your code contains \"nopush\" somewhere.. ; cf; fi'
#files
trash() {
mv $@ ~/.Trash
}
untrash() {
mv ~/.Trash/$1 .
}
alias t='trash'
alias unt='untrash'
alias trashcan='cd ~/.Trash'
alias emptytrash="echo 'For some reasons, this is too complicated. Just do it manually, bro.' "
alias rm="rm -i"
alias adaclean='find . -type f \( -name "*%" -o -name "*~" -o -name "~*" -o -name "*.DS_Store" \) -exec rm -rf {} \;' #remove ADA files *% *~ ~*
alias dsclean='find . -type f -name "*.DS_Store" -exec rm -rf {} \;'
alias l='ls -alhFo'
alias ll='ls -lhFo'
alias lS="l -S" # Size
alias lh="l -rt" # History
alias ly="l -T"
cdl() {
cd $1; l;
}
alias h="history -i -50"
alias diff="diff -bitw"
alias cx='chmod +x'
alias count='ls -1 | wc -l'
unalias g
g() {
grep --color -r $1 .
}
gi() { # Case insensitive
grep --color -ri $1 .
}
alias ghf='find . -type f | xargs grep --color' # grep hidden files
alias ghfi='gh -i' # grep hidden files (case insensitive)
fd() {
find . -iname "*$1*" 2>/dev/null
}
fdd() {
find . -iname $1 2>/dev/null # find the exact name
}
fdrm() {
cf; find . -iname "*$1*" 2>/dev/null -exec rm -rf {} \;
}
#automatic chmod (execution rights for folders, not for files) - apply to all subfolders
alias superchmod='find . -type d -exec chmod 0755 '{}' + -or -type f -exec chmod 0644 '{}' +'
# ----------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------
# ------------------------------------ GIT -------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------
# Undo, fix, or remove something in Git ? Try this ---> https://sethrobertson.github.io/GitFixUm/fixup.html
#
# Tuto git : How to remove a commit ?
# m
# git reset --hard c45f94e --> 1 commit before wrong commit
# git cherry-pick a5cda67
# git cherry-pick 3ecb317 --> all the commits that are after the wrong one, in the chronological order.
# ----------------
# Pour annuler un dernier commit pushed, et faire apparaitre l'annulation en tant que commit :
# git revert HEAD; gp;
# ----------------
#
alias gcc='git reset HEAD~' # -> Git Cancel Commit (a local one, without impacting files)
alias gccc='git reset --hard HEAD~' # -> Git Cancel Commit and drop modified files
alias revert='git revert HEAD' # Cancel last commit by commiting an opposite commit
# assume-unchanged VS skip-worktree : https://stackoverflow.com/a/13631525/5446285
alias skip='git update-index --skip-worktree' # ignore changes a file
alias unskip='git update-index --no-skip-worktree' # unignore changes a file
alias ignorelist="git ls-files -v | grep '^[[:lower:]]'"
# LOGS
unalias gl # To remove ZSH alias gl='git pull'
alias getLogVerbose='git --no-pager log \
--date=format:"%Y-%m-%d %H:%M:%S" \
--decorate=short \
--decorate-refs=refs/tags \
--pretty=format:"%C(yellow)%h%Creset %C(bold cyan)%d%Cgreen -- %ad %C(magenta)[%an]%Creset : %s"'
alias gitLogSimple='git --no-pager log \
--date=format:"%Y-%m-%d %H:%M:%S" \
--decorate=short \
--decorate-refs=refs/tags \
--pretty=format:"%C(yellow)%h%Creset %C(bold cyan)%d%Creset : %s"'
alias glv='getLogVerbose -20'
alias gls='gitLogSimple -20'
alias glf='glv --grep'
alias glad='git log --format=fuller' # git log all dates
alias gl+='git log --pretty=format:"%h -- %cd : %s" | more'
alias gla='git --no-pager log --pretty=format:"%C(yellow)%h%Cgreen -- %ad %C(magenta)[%an]%Creset : %s"; echo ""'
alias m='git --no-pager log --author="Jean Vallon" --pretty=format:"%C(yellow)%h%Cgreen -- %cd %C(magenta)[%an]%Creset : %s" ; echo ""' #my git log
alias glt='git --no-pager log --pretty=format:"%C(yellow)%h%Cgreen -- %cd %C(magenta)[%an]%Creset : %s" -20 $(git describe --tags --abbrev=0 @)\^..@; echo ""' #logs since last tags - requires at least two tags
# git log merge
glm() {
if [[ $1 == '' ]]
then
1=10
fi
gitLogSimple --merges -$1 $2
echo ""
}
# git log graph
unalias glg
glg() {
if [[ $1 == '' ]]
then
1=10
fi
gitLogSimple --graph --decorate -$1 $2
echo ""
}
GL() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == 'master' ]] || [[ $CURRENT_BRANCH == 'develop' ]] || [[ $CURRENT_BRANCH == 'main' ]]
then
glv --graph --decorate -$1
return
fi
if [[ $1 == '' ]]
then
1=3
fi
glv -$1 $2
echo ""
}
gl() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == 'master' ]] || [[ $CURRENT_BRANCH == 'develop' ]] || [[ $CURRENT_BRANCH == 'main' ]]
then
glg $1
return
fi
if [[ $1 == '' ]]
then
1=3
fi
gitLogSimple -$1 $2
echo ""
}
glr() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
gl 20 origin/$CURRENT_BRANCH
}
glcd() {
if [[ $1 == '' ]]
then
1=3
fi
git --no-pager log --date=format:"%Y-%m-%d %H:%M:%S" --pretty=format:"%C(yellow)%h%C(Cyan) -- %cd %C(magenta)[%an]%Creset : %s" -$1 $2
echo ""
}
alias gll='gl 20'
alias GLL='GL 20'
# wip commit
gcw() {
git commit --all -m "--WIP-- $1"
}
alias gs='git status'
unalias gst
gst() {
if [[ $1 == '' ]]
then
echo "⚠️ It is better to provide a message"
git stash
else
if [[ $2 != '' ]]
then
echo "Please provide one argument"
else
git stash push -m $1
fi
fi
}
# to create a tag on an old commit : git tag -a 0.1 fee9b02 -m "Message tag"
alias gt='git for-each-ref --format="%(refname:short) %(taggerdate) %(subject) %(body)" refs/tags'
alias gtLightweight='git for-each-ref --format="%(refname:short) %(committerdate) %(subject) %(body)" refs/tags'
alias gpt='git push --tags origin'
alias p='echo -e "\n\n\n"; gss; echo -e "\n----------------- GIT PULL ---------------------\n"; git pull'
alias pa='echo -e "\n\n\n"; gss; echo -e "\n----------------- GIT PULL ---------------------\n"; git pull --all'
alias gp='checknopush; echo -e "\n\n\n"; gss; echo -e "\n----------------- GIT PUSH ---------------------\n"; git push -u origin $(git rev-parse --abbrev-ref HEAD)' # $(...) = get local branch
alias gpa='checknopush; echo -e "\n\n\n"; gss; echo -e "\n----------------- GIT PUSH ---------------------\n"; git push --all -u origin'
alias gpf='cf; gp --force-with-lease'
alias GC='checknocommit; git commit'
alias gc='checknocommit; git commit -m'
alias gaa='git add --all'
alias gca='checknocommit; echo -e "\n\n\n"; gss; echo -e "\n------ GIT COMMIT STAGED & UNSTAGED FILES -----\n"; git commit -am'
alias grf='git checkout HEAD --' # To reset one file only
alias gck='kc; gc'
alias gcak='kc; gca'
alias ch='git checkout'
alias gcb='git checkout -b' # Same as ZSH
alias gm='git merge --no-ff --no-edit'
alias gmc='git merge --continue'
gcbp() {
git checkout -b $1 # Same as ZSH
git push -u origin $1
}
alias gb='git --no-pager branch --sort=committerdate --format="%(color:yellow)%(refname:short) %(color:magenta)[%(authorname)] (last commiter) %(color:green)%(authordate:format:%Y/%m/%d)" ' # Local branches ranged by recent date
alias gba='git --no-pager branch --sort=-committerdate --all' # All branches (unranged)
alias gbaa='git --no-pager branch --all' # All branches (unranged)
alias bb='gfa; echo "The current branches are :"; gba; echo -e "\n";'
alias gbr='git --no-pager branch --remote' # Same as ZSH
alias gfa='git fetch --all --prune' # Same as ZSH
alias gbd='git branch -d' # Same as ZSH
unalias gbD
gbD() {
echo "You are about to force delete the branch $1"
cf
git branch -D "$1"
}
alias gbda="echo 'WE WILL DELETE ALL LOCAL BRANCHES !!!'; cf; git branch | grep -v "master" | xargs git branch -D" # Delete all local branches
gbdr() {
echo You are about to delete the remote branch : $1; cf; git push origin --delete $1
}
#
# Delete remote branch AND local branch
del() { for i in $@
do
gbdr $i
gbd $i
done
}
#
# FORCE DELETE A BRANCH (remote and local)
delf() { for i in $@
do
# Delete remote branch AND local branch
gbdr $i
gbD $i
done
}
gbdms() { # s is for show
git branch --no-color --merged | grep -vE "^(\*|\s*(master|main|develop|dev|staging|preprod|sprint)\s*)"
} # show merged branches
gbdml() {
git branch --no-color --merged | grep -vE "^(\*|\s*(master|main|develop|dev|staging|preprod|sprint)\s*)" | xargs -n 1 git branch -d
} # delete MERGED local branches
gbdmr() {
git branch --no-color --merged | grep -vE "^(\*|\s*(master|main|develop|dev|staging|enrepreprod|sprint)\s*)" | xargs -n 1 git push origin --delete
} # delete MERGED remote branches - method is safe
gbdm() { #delete MERGED branches - method is safe
gfa
MERGED_BRANCHES=$(gbdms)
if [[ $MERGED_BRANCHES == '' ]]
then
echo No merged branches.
else
echo "Those branches are about to be deleted :"
echo $MERGED_BRANCHES
cf
gbdmr
gbdml
fi
}
alias trackallremotebranches='git branch -r | grep -v "\->" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done'
alias synchronizebranches="echo 'Make sure you pushed all your branches, otherwise last commits may be lost'; gbda; trackallremotebranches; gfa; pa;" # Synchronize all branches to remote
# Search a branch and show its location (local/remote)
alias grepbranch="git branch --all | grep" # git branch search
currentbranch() { # Current branch locations
git branch --all | grep $(git rev-parse --abbrev-ref HEAD)
}
alias grc='git rm --cached'
alias gconfig='n ~/.gitconfig'
alias gsa='git stash apply'
alias gurl='git config --get remote.origin.url' # get URL
alias ogurl='open $(git config --get remote.origin.url)' # open git URL
alias gn='git clean -f -d'
alias grr='gs; echo "\n⭐ Press enter if you want to CLEAN all created files.⭐\nIf nothing is red, just ignore it."; cf; git reset --hard; gn; echo "Everything is now up to date ! 😊"'
alias grh='cf; git reset --hard'
alias gdf='git diff --name-only' #only show names of files
alias gdd='git diff HEAD~'
alias gddf='git diff --name-only HEAD~' #only show names of files
alias gdl='gdn' # n pour names - l pour list
#alias maman="git parent" # (DOESN'T WORK IF BRANCH UP TO DATE WITH PARENT (?) + some other times..) -> avec comme alias dans gitconfig : parent = "!git show-branch | grep '*' | grep -v \"$(git rev-parse --abbrev-ref HEAD)\" | head -n1 | sed 's/.*\\[\\(.*\\)\\].*/\\1/' | sed 's/[\\^~].*//' #"
maman() {
git show-branch \
| sed "s/].*//" \
| grep "\*" \
| grep -v "$(git rev-parse --abbrev-ref HEAD)" \
| head -n1 \
| sed "s/^.*\[//"
}
alias mm='glb'
glb() { # LOG only commits from current BRANCH compared to another branch. Use : glb develop
echo "30 last commits only - Comparing current branch to $1 :"
git log --no-merges --pretty=format:"%h -- %cd : %s" -30 $1.. | cat
echo "\n"
}
alias gld=glb
glba() { # LOG only commits from current BRANCH compared to another branch. Use : glb develop
echo "30 last commits only - Comparing current branch to $1 :"
git log --no-merges --pretty=format:"%h -- %cd : %s" $1.. | cat
echo "\n"
}
glb+() { # LOG only commits from current BRANCH compared to another branch. Use : glb develop
echo "30 last commits only - Comparing current branch to $1 :"
git log --no-merges --pretty=format:"%h -- %cd : %s" -50 $1.. | more
echo "\n"
}
merge() { # This function can't be called 'gm' (it will break the world if you do that)
BASE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
FEATURE_BRANCH=$1
echo "\n###\n### Checking out feature branch $FEATURE_BRANCH"
ch --quiet $FEATURE_BRANCH
echo "\n###\n### Analyzing feature branch $FEATURE_BRANCH"
check
echo "\n###\n### Merge confirmation"
echo "You are about to merge \"$FEATURE_BRANCH\" into \"$BASE_BRANCH\"."
cf
echo "\n###\n### Merging"
ch --quiet $BASE_BRANCH
git merge $FEATURE_BRANCH --no-ff --no-edit
echo ""
echo "------------------------------------------------"
echo "If the merge hasn't succeeded, press CTRL+C"
echo "If there are errors, solve them and start again."
echo "If there are conflicts, you should do 'git merge --abort' and 'git rebase $FEATURE_BRANCH'"
echo "\n###\n### If the merge has succeeded, let's push the feature branch and the base branch."
cf
ch --quiet $FEATURE_BRANCH
gpf
ch --quiet $BASE_BRANCH
gp
echo "\n###\n### To remove the merge branch, use the command : gbdm"
}
mergeto() {
FEATURE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
BASE_BRANCH=$1
echo "\n###\n### Analyzing feature branch $FEATURE_BRANCH"
check
echo "\n###\n### Merge confirmation"
echo "You are about to merge \"$FEATURE_BRANCH\" into \"$BASE_BRANCH\"."
cf
echo "\n###\n### Merging"
ch --quiet $BASE_BRANCH
git merge $FEATURE_BRANCH --no-ff --no-edit
echo ""
echo "------------------------------------------------"
echo "If the merge hasn't succeeded, press CTRL+C"
echo "If there are errors, solve them and start again."
echo "If there are conflicts, you should do 'git merge --abort' and 'git rebase $FEATURE_BRANCH'"
echo "\n###\n### If the merge has succeeded, let's push the feature branch and the base branch."
cf
ch --quiet $FEATURE_BRANCH
gpf
ch --quiet $BASE_BRANCH
gp
echo "\n###\n### To remove the merge branch, use the command : gbdm"
}
# Usage : se placer sur la branch à renommer et taper "rename nouveau_nom"
renamebranch() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
git branch -m $1
git push origin :$CURRENT_BRANCH $1
git push origin -u $1
}
alias renamelocally='git branch -m'
alias gtdr='git push --delete origin'
alias gtdl='git tag --delete'
gtd() {
gtdr $1
gtdl $1
}
alias clonemirror='git clone --mirror'
alias pushmirror='git push --mirror'
alias get='git clone'
alias amend='git commit --amend -m'
alias am='git commit --amend'
alias suggestpushforce='gs; echo ""; echo "PRESS P TO PUSH FORCE (enter to abort) :"; read answerPush; if [[ $answerPush == 'P' ]] then git push --force-with-lease; fi'
alias oopsy='gs; echo ""; echo "⁉️ Merge STAGED FILES to last commit : $(git --no-pager log -1 --pretty=%B)"; cf; git commit --amend -v --no-edit; echo ""; suggestpushforce'
alias oopsall='gs; echo ""; echo "⁉️ Merge ALL FILES to last commit : $(git --no-pager log -1 --pretty=%B)"; cf; git commit --amend -v -a --no-edit; echo ""; suggestpushforce'
alias oopsallmessage='gs; echo ""; echo "⁉️ Merge ALL FILES to last commit : $(git --no-pager log -1 --pretty=%B)"; cf; git commit --amend -a; echo ""; suggestpushforce'
alias oo='oopsall'
alias om='oopsallmessage'
alias ot='oopsy' # Oops Tracked files
alias grcr='git rm --cached'
alias grcr='git rm --cached -r'
#History
alias Gh='git reflog --date=relative | cat' # History (only from HEAD) --> To get creation dates of branches !
alias Ghh='git reflog --date=iso | cat' # Idem with date not relative
alias Gha='git reflog --date=iso --all | cat' # History (all)
# ----------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------
# ------------------------------------ END OF GIT ------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------
# ----------------------------------------------------------------------------------------------------------------
#applications
alias garageband='open -a /Applications/GarageBand.app'
alias as="open -a /Applications/AndroidStudio.app" #usecase : $ as .
#quick files open
alias gitview='oi ~/Documents/devnotes/Mini-cours/Git/Workspace,\ index,\ local\ repository,\ remote\ repository.png'
alias androidversions='oi ~/dev/devnotes/android/android_versions.png'
alias gradleversions='oi ~/Documents/devnotes/gradle_versions.png'
alias spanish="oi /Users/jack/Documents/perso/Español/CONJUG_SPANISH.png"
alias sp="spanish"
ql () {
/usr/bin/qlmanage -p "$@" >& /dev/null &
} # "Quick Look"
# ----- 2019
alias x='dance'
alias bi='brew install'
alias space='echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"'
alias s='space'
alias n="sublime"
alias oi='open -a /System/Applications/Preview.app' # open image
alias o="open ." #pratique pour le finder
alias getip="ipconfig getifaddr en0" # wifi
alias getip2="ipconfig getifaddr en1" # ethernet
z() {
fileName=${1%%/}
fileName=${fileName%.*}
zip -r "${fileName}.zip" "$1" ;
echo "\nLe fichier ${fileName}.zip est prêt."
}
ze() {
fileName=${1%%/}
fileName=${fileName%.*}
zip --encrypt -r "${fileName}.zip" "$1" ;
echo "\nLe fichier ${fileName}.zip est prêt."
}
#Summer 2019
alias stay='caffeinate -d'
alias size='du -h -d 1 | sort -h' # all folders
alias size2='du -sch' # current folder only
alias size3='find . -maxdepth 1 -print0 | xargs -0 du -sh | sort -h' # all files and folders
# ----- DUCK ------
# -----------------
# ANSI COLOUR CODES
RD='\x1B[0;31m'
GR='\x1B[0;32m'
YL='\x1B[1;33m'
OR='\x1B[0;33m'
BL='\x1B[0;34m'
LBL='\x1B[1;34m'
CY='\x1B[1;36m'
NC='\x1B[0m' # No Color
# ASCII art startup
displayDuck() {
echo " __ \n ___( o)${OR}>${NC} \n \ <_. ) ${GR}V${NC} \n ${CY}~~~~~${NC}\`---'${CY}~~~~~${GR}|${CY}~~~${NC}\n"
}
alias jpp="displayDuck; echo 'Ah ça va mieux !!!'"
displayDuck # Display duck when open session in terminal
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
#2020
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
alias uninstall='brew uninstall --force'
nf() # stands for NEW FOLDER
{
mkdir -p -- "$1" &&
cd -P -- "$1"
}
alias duck='devnotes; cd NOTES/; n duck.txt'
alias clc='echo -n $(fc -ln -1) | pbcopy' # Copy Last Command
alias clo='$(echo $(fc -ln -1)) | pbcopy' # Copy Last Output
# Note : cplo does not work with aliases. Spent an hour on this it's impossible. But we can use Cmd+Shift+A
alias cpwd='echo -n $(pwd) | pbcopy'
alias admin='sudo -i'
w2m() {
wavName=$1
mp3Name=${wavName%.*}.mp3
ffmpeg -i $wavName $mp3Name #WAV to MP3
}
m2w() {
mp3Name=$1
wavName=${mp3Name%.*}.wav
ffmpeg -i $mp3Name $wavName #MP3 to WAV
}
mov2mp4() {
movName=$1
mp4Name=${movName%.*}.mp4
ffmpeg -i $movName $mp4Name
}
mov2avi() {
movName=$1
aviName=${movName%.*}.avi
ffmpeg -i $movName $aviName
}
mov2mkv() {
movName=$1
mkvName=${movName%.*}.mkv
ffmpeg -i $movName $mkvName
}
mov2gif() {
movName=$1
gifName=${movName%.*}.gif
ffmpeg -i $movName -filter:v "setpts=0.4*PTS" $gifName
# To accelerate video, reduce 0.4
# To slow down video, increase 0.4
}
mov2gifAccelerate() {
movName=$1
gifName=${movName%.*}.gif
ffmpeg -i $movName -filter:v "setpts=10*PTS" $gifName
}
compress() {
fullName=$1
compressedName=${fullName%.*}-compressed.mp4
ffmpeg -i $fullName -vcodec libx265 -crf 28 $compressedName
}
compressHalf() {
fullName=$1
compressedName=${fullName%.*}-compressed.mp4
ffmpeg -i $fullName -vf "scale=trunc(iw/4)*2:trunc(ih/4)*2" -vcodec libx265 -crf 28 $compressedName
}
compressThird() {
fullName=$1
compressedName=${fullName%.*}-compressed.mp4
ffmpeg -i $fullName "scale=trunc(iw/8)*2:trunc(ih/8)*2" -vcodec libx265 -crf 28 $compressedName
}
alias wt="curl wttr.in/Toulouse" # Weather Toulouse
alias cpaliasesenterprise="cat ~/Documents/devnotes/setup/files/aliases_enterprise.sh | pbcopy"
alias resetcntlm="killall cntlm; cntlm -c ~/cntlm.conf"
alias cleandebugger="adb shell am clear-debug-app" # When phone is stuck at "Waiting for Debugger"
alias fb="firebase"
# Flutter :
alias frc="flutter run -d chrome"
alias fra="flutter run -d all"
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
#2021
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
getPreffix() {
fileName=$1
return ${fileName##*.}
}
alias prefix='echo "[clean] \n[fix] \n[wip] \n[wording] \n[doc] \n[merge] \n[refacto]"'
alias cleanderiveddata='rm -rf ~/Library/Developer/Xcode/DerivedData'
setupstream() {
git branch --set-upstream-to=origin/$1 $1
}
alias lastFileModified='find . -type f -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -1 | cut -f2- -d" "'
alias fpg='flutter pub get'
alias fpum='flutter pub upgrade --major-versions'
alias fpu='flutter pub upgrade'
alias cleanupgrade='flutter clean; rm -f pubspec.lock; flutter pub upgrade; build;' # "rm -f pubspec.lock " is necessary (tested on Oct 2023 and Nov 2023)
alias cleanget='flutter clean; rm -f pubspec.lock; flutter pub get; build'
alias cu='cleanupgrade'
alias cg='cleanget'
alias cleanios='echo "Disable dart watcher now !"; cf; flutter clean; cd ios/; rm -f Podfile.lock; rm -rf Pods/; pod repo update; pod install; cd ../; fpg; build; build;' #From https://stackoverflow.com/questions/64443888/flutter-cocoapodss-specs-repository-is-too-out-of-date-to-satisfy-dependencies --> Despite that I have the message "Cocoapods is not installed" if I don't do "pod install" and run with shift+cmd+d
alias ci=cleanios
alias cleanios2='echo "This will clean derived data and reinstall pods. Only do it if the simple clean does not work. Please disable dart watcher now !"; cf; flutter clean; rm -rf ~/Library/Developer/Xcode/DerivedData/*; cd ios/; rm -f Podfile.lock; rm -rf Pods/; pod deintegrate; pod install --repo-update; cd ../; fpg; build; build;'
alias ci2=cleanios2
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
#2022
# -----------------------------------------------------------------------------------------------------------------------------------------------------------
# ---
# Git operations for new temp branches
# ------------------------------------------------------------------------
abort() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == 'master' ]] || [[ $CURRENT_BRANCH == 'develop' ]]
then
echo "You can't abort if you are on master or develop."
else
ch develop
echo ""
echo "On develop, edits are :"
git status -s
echo ""
echo "No errors above ? This local branch is about to be deleted : $CURRENT_BRANCH"
cf
gbD $CURRENT_BRANCH
fi
}
alias ab='abort'
alias nb='gcb new-feature'
mergebranchintodevelop() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == 'master' ]] || [[ $CURRENT_BRANCH == 'develop' ]]
then
echo "You can't merge in develop if you are on master or develop."
else
echo ""
echo "On $CURRENT_BRANCH, commits are :"
glb develop
echo ""
echo "Ready to merge those changes into develop ?"
cf
ch develop
git merge $CURRENT_BRANCH
echo ""
echo "Remove branch $CURRENT_BRANCH ?"
cf
gbd $CURRENT_BRANCH
gp
fi
}
alias mb="mergebranchintodevelop"
alias lb="echo 'Git status :'; git status -s; echo ''; glb develop"
# ------------------------------------------------------------------------
reinstallwithbrew() {
lib=$1
brew uninstall $lib
brew install $lib
sudo brew link $lib
}
alias fv='flutter --version'
deliverIOS() {
echo "Type the flavor, no caps : "
read flavor
rm -f pubspec.lock; flutter clean; flutter pub get; cd ios;t Podfile.lock; pod install
flutter build ipa --flavor $flavor -t lib/run/main-$flavor.dart --export-options-plist=ios/ExportOptions-$flavor.plist
echo ""
echo "✅"
echo ""
echo "The IPA is located in : $PWD/build/release/"
echo ""
}
alias di="deliverIOS"
deliverAndroid() {
echo "Type the flavor, no caps : "
read flavor
flutter build apk --flavor $flavor -t lib/run/main-$flavor.dart
echo ""
echo "✅"
echo ""
echo "The APK is located in : build/app/outputs/flutter-apk/"
echo ""
}
alias da="deliverAndroid"
upgradeBuildNumber() {
# Find and increment the version number.
perl -i -pe 's/^(version:\s+\d+\.\d+\.\d+\+)(\d+)$/$1.($2+1)/e' pubspec.yaml
# Commit and tag this change.
version=`grep 'version: ' pubspec.yaml | sed 's/version: //'`
echo "Commit message : FINISH - $1 - Bump version to $version"
git commit -m "FINISH - $1 - Bump version to $version" pubspec.yaml
git tag $version -m "Feature - $1"
}
alias up='upgradeBuildNumber'
upgradeVersion() {
cd FRONT_app/
cd cdapp/
# get actual version
currentVersion=`grep 'version: ' pubspec.yaml | sed 's/version: //'`
# ask new version
echo "Your current version is $currentVersion"
echo "What is the name of your new version ?"
read newVersion
# Find and increment the version number.
sed -i '' "s/version: $currentVersion/version: $newVersion/" pubspec.yaml
# Commit and tag this change.
echo ""
echo "Commit message : RELEASE : $1 - Bump version to $newVersion"
git commit -m "RELEASE : $1 - Bump version to $newVersion" pubspec.yaml
git tag $newVersion -m "Feature : $1"
# Push ?
echo ""
echo "Here are the changes :"
git --no-pager diff HEAD~
echo ""
echo ""
echo "Do you want to push ? [Y/N]"
read answerPush
if [[ $answerPush == 'Y' ]]
then
git push
git push --tags origin
fi
}
# ------------------------------------------------------------------------
# EXOD
# ------------------------------------------------------------------------
alias ms='flutter clean; flutter pub get; make store-generate'
alias unstage='git reset' # unstage /path/to/file
trim() {
echo "Hello, welcome to the Upside World."
echo "If you're here, I believe you want to trim your video."
echo "You came to the right place."
echo "I will ask you three questions."
echo "Answer wisely."
echo ""
echo "What's the name of your video ?"
read name
echo "What's the new beginning ? (Format : HH:MM:SS)"
read beginning
echo "What's the new ending ? (Format : HH:MM:SS)"
read ending
echo "Quelle est l'extension souhaitée (mov, mp4 ...)"
read extension
echo ""
echo "C'est votre dernier mot ?"
read
outputname=${name%.*}-trimmed.$extension
ffmpeg -ss $beginning -t $ending -i $name -vcodec copy -acodec copy $outputname
}
trim135() {
beginning='00:00:00'
ending='00:01:35'
extension=mp3
for name in "$@"; do
echo "Processing $name..."
outputname=${name%.*}-trimmed.$extension
ffmpeg -ss $beginning -t $ending -i "$name" -filter_complex "aevalsrc=0:d=5 [a_silence]; [0:a:0] [a_silence] acrossfade=d=5" "$outputname"
done
}
# ------------------------------------------------------------------------
# CANADA
# ------------------------------------------------------------------------
alias unlock='chflags -R nouchg' # Can be applied to a folder, it will unlock all containing files
# this apply to all subfolders and subfiles
normalchmod() {
find . -type d -print0 | xargs -0 chmod 755
find . -type f -print0 | xargs -0 chmod 644
find . -type f -iname "*.sh" -print0 | xargs -0 chmod +x
}
createrepo() {
if [[ $1 == '' ]]
then
echo Please provide the name of the repo.
else
git init
git add --all
git status
git commit -m "First commit 🦋"
gh repo create $1 --private
git remote add origin https://github.com/icodeyou/$1.git
git push -u origin main
fi
}
fluttercreate() {
cdp
echo "Enter the name of the project :"
read project
defaultOrgName="com.icodeyou.$1"
echo "Do you want to use the bundle $defaultOrgName? Press return key for OK, right 'no' instead."
read answer
if [[ $answer == '' ]]
then
org=$$defaultOrgName
else
echo "Enter bundle name (ex : com.example.app) :"
read bundle
org=$bundle
fi
flutter create --org $org $project
cp ../BUTTERFLY_PROJECT/butterfly/.gitignore $project/
cd $project/
createrepo $project
git push
}
alias build='cc; dart run build_runner build --delete-conflicting-outputs'
alias watch='dart run build_runner watch --delete-conflicting-outputs'
alias w=watch
alias ww='while true; do dart run build_runner watch --delete-conflicting-outputs; sleep 1; done'
alias diffn='diff -qr' # diff names
alias gmd='git merge develop'
# ------------------------------------------------------------------------
# BAM
# ------------------------------------------------------------------------
alias dd='d ~/.``ssh``/;` `ssh``-add'
alias rb5='grbi HEAD~5' # Not recommended (better to compare to a parent branch)
alias rbm='grbi master'
alias rbd='grbi develop'
alias rb='grbi develop'
alias mn='make -n'
alias show='git --no-pager show'
alias shown="git --no-pager show $1 --name-only"
chh() {
initialPath=$PWD
cd ..
cd FRONT_app
git checkout $1
make gen_l10n
cd cdapp
flutter pub get
cd ..
cd cdapp_theme
flutter pub get
cd $initialPath
}
alias ]]='chh $(git rev-parse --abbrev-ref HEAD)'
drop() {
cf
COMMITHASH=$1
GIT_SEQUENCE_EDITOR="sed -i -re 's/^pick $COMMITHASH/d $COMMITHASH/'" git rebase -i $COMMITHASH~
}
reword() {
cf
COMMITHASH=$1
GIT_SEQUENCE_EDITOR="sed -i -re 's/^pick $COMMITHASH/r $COMMITHASH/'" git rebase -i $COMMITHASH~
}
alias r='reword'
edit() {
COMMITHASH=$1
GIT_SEQUENCE_EDITOR="sed -i -re 's/^pick $COMMITHASH/e $COMMITHASH/'" git rebase -i $COMMITHASH~
}
alias e='edit'
# Wow. November 15th, 2022, 1am. I spent two hours on this.
replace() {
COMMIT_HASH_TO_REPLACE=$1
NEW_COMMIT_HASH=$2
echo "Commit $COMMIT_HASH_TO_REPLACE will be replaced by $NEW_COMMIT_HASH"
cf
GIT_SEQUENCE_EDITOR="sed -i -re 's/^pick $COMMIT_HASH_TO_REPLACE/pick $NEW_COMMIT_HASH/'" git rebase -i --reapply-cherry-picks $COMMIT_HASH_TO_REPLACE~
}
split() {
echo "What is the hash of the commit you want to split ?"
read SPLIT_HASH
echo "What was the hash of the commit before you accidently amended it ?"
read OLD_HASH
replace $SPLIT_HASH $OLD_HASH
git cherry-pick -e $SPLIT_HASH
}
# amend author date and commit date
# Note : To commit another commit, just do "edit #hash" before
gad() {
echo "Enter the desired date at the following format : $(date)"
read DATE
LC_ALL=C GIT_COMMITTER_DATE="$DATE" git commit --amend --no-edit --date "$DATE"
}
alias gadn='cf; git commit --amend --reset-author --no-edit' # amend author date and commit date to now()
alias gacd='cf; GIT_COMMITTER_DATE=$(date) git commit --amend --no-edit' # amend commit date only to now()
alias gitsp='git stash push -p' # usage : "gitsp xx/yy.dart; a" or : "gitsp" --> and we select each files
alias shelve='git add -p' # STAGE PARTS OF FILES !!!! 🎈 🎉
alias gap='git add -p'
deleteTempBranches() {
git branch -D `git branch --list 'jean-temp*'`
}
alias c.='code .'
# ------------------------------------------------------------------------
# ❤️ 2023 ❤️
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# MEDES
alias dummy='touch trouble $(openssl rand -hex 10); git add .; git commit -m'
alias fixup='git commit --fixup'
alias fixupall='git add --all; fixup'
sq() {
export GIT_EDITOR=TRUE
git rebase --autosquash --interactive $1
suggestpushforce
}
f() { # All files. Use : `f COMMIT_HASH`
fixupall $1
sq $1~
}
fh() { # All files. Use : `fh`
fixupall HEAD
sq HEAD~
}
ff() { # Only commited files. Use : `ff COMMIT_HASH`
fixup $1
gst
sq $1~
gsp
} # Only commited files. Use : `ffh`
ffh() {
fixup HEAD
gst
sq HEAD~
gsp
}
alias dfa='dart fix --apply'
alias glbd='glb develop'
pp() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == 'feat' ]] || [[ $CURRENT_BRANCH == 'develop'* ]]
then
echo Wrong source branch
echo No branches have been deleted.
else
git checkout develop
git pull
git branch -d $CURRENT_BRANCH
echo $CURRENT_BRANCH has been deleted.
fi
}
ppm() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == 'feat' ]] || [[ $CURRENT_BRANCH == 'master'* ]]
then
echo Wrong source branch
echo No branches have been deleted.
else
git checkout master
git pull
git branch -d $CURRENT_BRANCH
echo $CURRENT_BRANCH has been deleted.
fi
}
alias ppmaster='ppm'
alias ppdoc='ppm'
ppc() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == 'feat' ]] || [[ $CURRENT_BRANCH == 'cross_platform'* ]]
then
echo Wrong source branch
echo No branches have been deleted.
else
git checkout cross_platform
git pull
git branch -d $CURRENT_BRANCH
echo $CURRENT_BRANCH has been deleted.
fi
}
ppnutri() {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $CURRENT_BRANCH == 'feat' ]] || [[ $CURRENT_BRANCH == 'develop'* ]]
then
echo Wrong source branch
echo No branches have been deleted.
else
git checkout develop
git pull
git merge $CURRENT_BRANCH
git branch -d $CURRENT_BRANCH
echo $CURRENT_BRANCH has been deleted.
gp
fi
}
alias ppn=ppnutri
# To display previous directories : Type "cd -" + TAB
# To quickly type a directory, do : "/u/j/d" + TAB
alias gpr='git pull --rebase origin'
alias rd='git pull --rebase origin develop'
alias rc='git pull --rebase origin cross_platform'
alias issue="glab issue create --assignee Jean --label enhancement --description '' -t"
alias issued="glab issue create --assignee Jean --label enhancement -t"
alias issuel="glab issue list --assignee Jean | cat"
# Examples :
# mr 7 'add counter button'
# mr 'add counter button'
mr() {
gp
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [[ $1 == '' ]]
then
1=$CURRENT_BRANCH
fi
if [[ $2 == '' ]]
then
glab mr create --fill --reviewer anthony.libet --source-branch $CURRENT_BRANCH --yes -t "$1"
else
glab mr create --fill --reviewer anthony.libet --source-branch $CURRENT_BRANCH --yes -i "#$1" -t "$2"
glab mr update --ready # The only way according to this : https://github.com/profclems/glab/issues/17
fi
}
alias mrm='glab mr merge; pp'
alias slang='dart run slang'
alias sl=slang
unalias gg
# This command can run with Bash !
# This is necessary for script report-changes.sh in hello_riverpod
gg() {
git add --all
git status
echo ""
echo "⚠️ Those changes will be committed on snowball and master. Ready ?"
cfs
git commit --no-verify -m "$1"
LAST_COMMIT_HASH=$(git rev-parse HEAD)
git checkout master
git cherry-pick $LAST_COMMIT_HASH
echo ""
echo "✅ Commits are done"
echo ""
echo "Press 'p' if you want to push."
# There is no equivalent to "read -sk" in bash, so we have to type enter
read answer
if [[ $answer == "p" ]] || [[ $answer == "P" ]]
then
echo "Start pushing ..."
echo ""
git push
git checkout -
git push
else
git checkout -
fi
}
alias yoss='read -k 1 -r'
alias gsl='git stash list --date=local | tail -r'
alias gsc='gsl; echo ""; echo "You are about to clear the stash list."; cf; git stash clear'
alias fpa='flutter pub add'
alias fpad='flutter pub add --dev'
# ------------------------------------------------------------------------
# ❤️ 2024
# ------------------------------------------------------------------------
alias flutterkick='echo "Your problem has been solved."' # For Antoine MEDES
alias moveApps='devnotes; ./setup/files/move_new_apps.sh'
# init local
il() {
cd LOCAL
git init
git add --all
git commit -m 'first commit'
}
findCommitForFile() {
git log --all --pretty=format:"%h %ad" --name-only --date=short | grep -B 1 "$1"
}
alias fpo='flutter pub outdated'
alias gen='hr; ./gen.sh snowball'
alias showf='git show --name-only'
# ------------ Tasks
alias tm='task modify'
alias to='task oldest'
alias tu='task next' # Most urgent tasks - It seems to be equal to "t"
alias ta="task add $1 due:now"
alias tak="task add $1 due:now project:kaizen"
alias tap="task add $1 due:now project:pixtory"
alias tam="task add $1 due:now project:pixtory +marketing"
alias tab="task add $1 due:now project:pixtory +business"
alias tad="task add $1 due:now project:pixtory +dev"
alias tadb="task add $1 due:now project:pixtory +dev +bug"
alias ts='task start'
alias tsp='task stop'
alias tA='task all' # WE CANNOT SORT THOSE (even with task list etc.. Tried everything)
alias tr="task $1 delete" # task remove
alias trestore="task $1 modify status:pending" # task restore
alias td="task $1 done"
alias tt='task due.before:tomorrow+4h' # Task Today
alias tc='task end:today completed' # Displayed in order of completion
alias tca='task completed' # ALL completed tasks
alias tz='task undo' # Cmd+Z
alias tdate='task list ' # Just like 'tu' without priority order, and full due date
alias tmini='task minimal'
# ------------
# ------------------------------------------------------------------------
# ❤️ 2025
# ------------------------------------------------------------------------
alias loveyourself="echo '🤗 🎁 ➡️ 💛"
alias b="build"
alias cleanStatusBar='xcrun simctl status_bar booted override --time 09:41 --batteryState charged --batteryLevel 100 --cellularBars 4'
alias resetStatusBar='xcrun simctl status_bar booted clear'
alias emulator='/Users/jack/Library/Android/sdk/emulator/emulator'
alias simandroid='emulator -avd Pixel_3a_API_29_x86 &'
alias simios='open -a Simulator; sleep 5; echo "Cleaning status bar"; cleanStatusBar'
alias timestamp="date +%s"
calculate_billion_birthday() {
echo "🚀 Let's calculate your million-second birthday! 🎉"
echo ""
echo "📅 Enter your birth date (format: YYYY-MM-DD HH:MM:SS)"
echo -n "👉 "
read birthdate
if [ -z "$birthdate" ]; then
echo "⚠️ No input provided!"
return 1
fi
birth_ts=$(date -j -f "%Y-%m-%d %H:%M:%S" "$birthdate" "+%s" 2>/dev/null)
if [ -z "$birth_ts" ]; then
echo "❌ Invalid date format. Please use: YYYY-MM-DD HH:MM:SS"
return 1
fi
billion_birthday_ts=$((birth_ts + 1000000000))
billion_birthday=$(date -r "$billion_birthday_ts" "+%Y-%m-%d %H:%M:%S")
echo ""
echo "🎉 You will be 1,000,000,000 seconds old on:"
echo "👉 $billion_birthday"
echo ""
}
alias clocflutter='cloc lib --by-file -exclude-ext=freezed.dart,g.dart'
alias getLinesOfCode=clocflutter
alias gcaw="gca '[WIP]'"
stats24() {
git log --since="24 hours ago" --shortstat --pretty="" | awk '/insertion/ {ins+=$4; del+=$6} END {print "Insertions:", ins, "Deletions:", del}'
}
stats72() {
git log --since="72 hours ago" --shortstat --pretty="" | awk '/insertion/ {ins+=$4; del+=$6} END {print "Insertions:", ins, "Deletions:", del}'
}
totalStats() {
git log --shortstat --pretty="" | awk '/insertion/ {ins+=$4; del+=$6} END {print "Insertions:", ins, "Deletions:", del}'
}
alias stats=stats24
alias cdsim='cd ~/Library/Developer/CoreSimulator/Devices' #simulator path
# ---------------------------------------------------
OH MY ZSH
# ---------------------------------------------------
# Git version checking
autoload -Uz is-at-least
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
#
# Functions Current
# (sorted alphabetically by function name)
# (order should follow README)
#
# The name of the current branch
# Back-compatibility wrapper for when this function was defined here in
# the plugin, before being pulled in to core lib/git.zsh as git_current_branch()
# to fix the core -> git plugin dependency.
function current_branch() {
git_current_branch
}
# Check for develop and similarly named branches
function git_develop_branch() {
command git rev-parse --git-dir &>/dev/null || return
local branch
for branch in dev devel develop development; do
if command git show-ref -q --verify refs/heads/$branch; then
echo $branch
return 0
fi
done
echo develop
return 1
}
# Get the default branch name from common branch names or fallback to remote HEAD
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return
local remote ref
for ref in refs/{heads,remotes/{origin,upstream}}/{main,trunk,mainline,default,stable,master}; do
if command git show-ref -q --verify $ref; then
echo ${ref:t}
return 0
fi
done
# Fallback: try to get the default branch from remote HEAD symbolic refs
for remote in origin upstream; do
ref=$(command git rev-parse --abbrev-ref $remote/HEAD 2>/dev/null)
if [[ $ref == $remote/* ]]; then
echo ${ref#"$remote/"}; return 0
fi
done
# If no main branch was found, fall back to master but return error
echo master
return 1
}
function grename() {
if [[ -z "$1" || -z "$2" ]]; then
echo "Usage: $0 old_branch new_branch"
return 1
fi
# Rename branch locally
git branch -m "$1" "$2"
# Rename branch in origin remote
if git push origin :"$1"; then
git push --set-upstream origin "$2"
fi
}
#
# Functions Work in Progress (WIP)
# (sorted alphabetically by function name)
# (order should follow README)
#
# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one
function gunwipall() {
local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H)
# Check if a commit without "--wip--" was found and it's not the same as HEAD
if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then
git reset $_commit || return 1
fi
}
# Warn if the current branch is a WIP
function work_in_progress() {
command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
}
#
# Aliases
# (sorted alphabetically by command)
# (order should follow README)
# (in some cases force the alias order to match README, like for example gke and gk)
#
alias grt='cd "$(git rev-parse --show-toplevel || echo .)"'
function ggpnp() {
if [[ "$#" == 0 ]]; then
ggl && ggp
else
ggl "${*}" && ggp "${*}"
fi
}
compdef _git ggpnp=git-checkout
alias ggpur='ggu'
alias g='git'
alias ga='git add'
alias gaa='git add --all'
alias gapa='git add --patch'
alias gau='git add --update'
alias gav='git add --verbose'
alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commit --no-verify --no-gpg-sign --message "--wip-- [skip ci]"'
alias gam='git am'
alias gama='git am --abort'
alias gamc='git am --continue'
alias gamscp='git am --show-current-patch'
alias gams='git am --skip'
alias gap='git apply'
alias gapt='git apply --3way'
alias gbs='git bisect'
alias gbsb='git bisect bad'
alias gbsg='git bisect good'
alias gbsn='git bisect new'
alias gbso='git bisect old'
alias gbsr='git bisect reset'
alias gbss='git bisect start'
alias gbl='git blame -w'
alias gb='git branch'
alias gba='git branch --all'
alias gbd='git branch --delete'
alias gbD='git branch --delete --force'
function gbda() {
git branch --no-color --merged | command grep -vE "^([+*]|\s*($(git_main_branch)|$(git_develop_branch))\s*$)" | command xargs git branch --delete 2>/dev/null
}
# Copied and modified from James Roeder (jmaroeder) under MIT License
# https://github.com/jmaroeder/plugin-git/blob/216723ef4f9e8dde399661c39c80bdf73f4076c4/functions/gbda.fish
function gbds() {
local default_branch=$(git_main_branch)
(( ! $? )) || default_branch=$(git_develop_branch)
git for-each-ref refs/heads/ "--format=%(refname:short)" | \
while read branch; do
local merge_base=$(git merge-base $default_branch $branch)
if [[ $(git cherry $default_branch $(git commit-tree $(git rev-parse $branch\^{tree}) -p $merge_base -m _)) = -* ]]; then
git branch -D $branch
fi
done
}
alias gbgd='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -d'
alias gbgD='LANG=C git branch --no-color -vv | grep ": gone\]" | cut -c 3- | awk '"'"'{print $1}'"'"' | xargs git branch -D'
alias gbm='git branch --move'
alias gbnm='git branch --no-merged'
alias gbr='git branch --remote'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gbg='LANG=C git branch -vv | grep ": gone\]"'
alias gco='git checkout'
alias gcor='git checkout --recurse-submodules'
alias gcb='git checkout -b'
alias gcB='git checkout -B'
alias gcd='git checkout $(git_develop_branch)'
alias gcm='git checkout $(git_main_branch)'
alias gcp='git cherry-pick'
alias gcpa='git cherry-pick --abort'
alias gcpc='git cherry-pick --continue'
alias gclean='git clean --interactive -d'
alias gcl='git clone --recurse-submodules'
alias gclf='git clone --recursive --shallow-submodules --filter=blob:none --also-filter-submodules'
function gccd() {
setopt localoptions extendedglob
# get repo URI from args based on valid formats: https://git-scm.com/docs/git-clone#URLS
local repo="${${@[(r)(ssh://*|git://*|ftp(s)#://*|http(s)#://*|*@*)(.git/#)#]}:-$_}"
# clone repository and exit if it fails
command git clone --recurse-submodules "$@" || return
# if last arg passed was a directory, that's where the repo was cloned
# otherwise parse the repo URI and use the last part as the directory
[[ -d "$_" ]] && cd "$_" || cd "${${repo:t}%.git/#}"
}
compdef _git gccd=git-clone
alias gcam='git commit --all --message'
alias gcas='git commit --all --signoff'
alias gcasm='git commit --all --signoff --message'
alias gcs='git commit --gpg-sign'
alias gcss='git commit --gpg-sign --signoff'
alias gcssm='git commit --gpg-sign --signoff --message'
alias gcmsg='git commit --message'
alias gcsm='git commit --signoff --message'
alias gc='git commit --verbose'
alias gca='git commit --verbose --all'
alias gca!='git commit --verbose --all --amend'
alias gcan!='git commit --verbose --all --no-edit --amend'
alias gcans!='git commit --verbose --all --signoff --no-edit --amend'
alias gcann!='git commit --verbose --all --date=now --no-edit --amend'
alias gc!='git commit --verbose --amend'
alias gcn='git commit --verbose --no-edit'
alias gcn!='git commit --verbose --no-edit --amend'
alias gcf='git config --list'
alias gcfu='git commit --fixup'
alias gdct='git describe --tags $(git rev-list --tags --max-count=1)'
alias gd='git diff'
alias gdca='git diff --cached'
alias gdcw='git diff --cached --word-diff'
alias gds='git diff --staged'
alias gdw='git diff --word-diff'
function gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gdup='git diff @{upstream}'
function gdnolock() {
git diff "$@" ":(exclude)package-lock.json" ":(exclude)*.lock"
}
compdef _git gdnolock=git-diff
alias gdt='git diff-tree --no-commit-id --name-only -r'
alias gf='git fetch'
# --jobs=<n> was added in git 2.8
is-at-least 2.8 "$git_version" \
&& alias gfa='git fetch --all --tags --prune --jobs=10' \
|| alias gfa='git fetch --all --tags --prune'
alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'
alias ghh='git help'
alias glgg='git log --graph'
alias glgga='git log --graph --decorate --all'
alias glgm='git log --graph --max-count=10'
alias glods='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset" --date=short'
alias glod='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset"'
alias glola='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --all'
alias glols='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset" --stat'
alias glol='git log --graph --pretty="%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset"'
alias glo='git log --oneline --decorate'
alias glog='git log --oneline --decorate --graph'
alias gloga='git log --oneline --decorate --graph --all'
# Pretty log messages
function _git_log_prettily(){
if ! [ -z $1 ]; then
git log --pretty=$1
fi
}
compdef _git _git_log_prettily=git-log
alias glp='_git_log_prettily'
alias glg='git log --stat'
alias glgp='git log --stat --patch'
alias gignored='git ls-files -v | grep "^[[:lower:]]"'
alias gfg='git ls-files | grep'
alias gm='git merge'
alias gma='git merge --abort'
alias gmc='git merge --continue'
alias gms="git merge --squash"
alias gmff="git merge --ff-only"
alias gmom='git merge origin/$(git_main_branch)'
alias gmum='git merge upstream/$(git_main_branch)'
alias gmtl='git mergetool --no-prompt'
alias gmtlvim='git mergetool --no-prompt --tool=vimdiff'
alias gl='git pull'
alias gpr='git pull --rebase'
alias gprv='git pull --rebase -v'
alias gpra='git pull --rebase --autostash'
alias gprav='git pull --rebase --autostash -v'
function ggu() {
local b
[[ "$#" != 1 ]] && b="$(git_current_branch)"
git pull --rebase origin "${b:-$1}"
}
compdef _git ggu=git-pull
alias gprom='git pull --rebase origin $(git_main_branch)'
alias gpromi='git pull --rebase=interactive origin $(git_main_branch)'
alias gprum='git pull --rebase upstream $(git_main_branch)'
alias gprumi='git pull --rebase=interactive upstream $(git_main_branch)'
alias ggpull='git pull origin "$(git_current_branch)"'
function ggl() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git pull origin "${*}"
else
local b
[[ "$#" == 0 ]] && b="$(git_current_branch)"
git pull origin "${b:-$1}"
fi
}
compdef _git ggl=git-pull
alias gluc='git pull upstream $(git_current_branch)'
alias glum='git pull upstream $(git_main_branch)'
alias gp='git push'
alias gpd='git push --dry-run'
function ggf() {
local b
[[ "$#" != 1 ]] && b="$(git_current_branch)"
git push --force origin "${b:-$1}"
}
compdef _git ggf=git-push
alias gpf!='git push --force'
is-at-least 2.30 "$git_version" \
&& alias gpf='git push --force-with-lease --force-if-includes' \
|| alias gpf='git push --force-with-lease'
function ggfl() {
local b
[[ "$#" != 1 ]] && b="$(git_current_branch)"
git push --force-with-lease origin "${b:-$1}"
}
compdef _git ggfl=git-push
alias gpsup='git push --set-upstream origin $(git_current_branch)'
is-at-least 2.30 "$git_version" \
&& alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease --force-if-includes' \
|| alias gpsupf='git push --set-upstream origin $(git_current_branch) --force-with-lease'
alias gpv='git push --verbose'
alias gpoat='git push origin --all && git push origin --tags'
alias gpod='git push origin --delete'
alias ggpush='git push origin "$(git_current_branch)"'
function ggp() {
if [[ "$#" != 0 ]] && [[ "$#" != 1 ]]; then
git push origin "${*}"
else
local b
[[ "$#" == 0 ]] && b="$(git_current_branch)"
git push origin "${b:-$1}"
fi
}
compdef _git ggp=git-push
alias gpu='git push upstream'
alias grb='git rebase'
alias grba='git rebase --abort'
alias grbc='git rebase --continue'
alias grbi='git rebase --interactive'
alias grbo='git rebase --onto'
alias grbs='git rebase --skip'
alias grbd='git rebase $(git_develop_branch)'
alias grbm='git rebase $(git_main_branch)'
alias grbom='git rebase origin/$(git_main_branch)'
alias grbum='git rebase upstream/$(git_main_branch)'
alias grf='git reflog'
alias gr='git remote'
alias grv='git remote --verbose'
alias gra='git remote add'
alias grrm='git remote remove'
alias grmv='git remote rename'
alias grset='git remote set-url'
alias grup='git remote update'
alias grh='git reset'
alias gru='git reset --'
alias grhh='git reset --hard'
alias grhk='git reset --keep'
alias grhs='git reset --soft'
alias gpristine='git reset --hard && git clean --force -dfx'
alias gwipe='git reset --hard && git clean --force -df'
alias groh='git reset origin/$(git_current_branch) --hard'
alias grs='git restore'
alias grss='git restore --source'
alias grst='git restore --staged'
alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1'
alias grev='git revert'
alias greva='git revert --abort'
alias grevc='git revert --continue'
alias grm='git rm'
alias grmc='git rm --cached'
alias gcount='git shortlog --summary --numbered'
alias gsh='git show'
alias gsps='git show --pretty=short --show-signature'
alias gstall='git stash --all'
alias gstaa='git stash apply'
alias gstc='git stash clear'
alias gstd='git stash drop'
alias gstl='git stash list'
alias gstp='git stash pop'
# use the default stash push on git 2.13 and newer
is-at-least 2.13 "$git_version" \
&& alias gsta='git stash push' \
|| alias gsta='git stash save'
alias gsts='git stash show --patch'
alias gst='git status'
alias gss='git status --short'
alias gsb='git status --short --branch'
alias gsi='git submodule init'
alias gsu='git submodule update'
alias gsd='git svn dcommit'
alias git-svn-dcommit-push='git svn dcommit && git push github $(git_main_branch):svntrunk'
alias gsr='git svn rebase'
alias gsw='git switch'
alias gswc='git switch --create'
alias gswd='git switch $(git_develop_branch)'
alias gswm='git switch $(git_main_branch)'
alias gta='git tag --annotate'
alias gts='git tag --sign'
alias gtv='git tag | sort -V'
alias gignore='git update-index --assume-unchanged'
alias gunignore='git update-index --no-assume-unchanged'
alias gwch='git log --patch --abbrev-commit --pretty=medium --raw'
alias gwt='git worktree'
alias gwta='git worktree add'
alias gwtls='git worktree list'
alias gwtmv='git worktree move'
alias gwtrm='git worktree remove'
alias gstu='gsta --include-untracked'
alias gtl='gtl(){ git tag --sort=-v:refname -n --list "${1}*" }; noglob gtl'
alias gk='\gitk --all --branches &!'
alias gke='\gitk --all $(git log --walk-reflogs --pretty=%h) &!'
unset git_version
# Logic for adding warnings on deprecated aliases
local old_alias new_alias
for old_alias new_alias (
# TODO(2023-10-19): remove deprecated `git pull --rebase` aliases
gup gpr
gupv gprv
gupa gpra
gupav gprav
gupom gprom
gupomi gpromi
); do
aliases[$old_alias]="
print -Pu2 \"%F{yellow}[oh-my-zsh] '%F{red}${old_alias}%F{yellow}' is a deprecated alias, using '%F{green}${new_alias}%F{yellow}' instead.%f\"
$new_alias"
done
unset old_alias new_alias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment