Last active
June 5, 2019 19:33
-
-
Save LongBu/1522392e3a6e207a4030a2a8ce3d9c66 to your computer and use it in GitHub Desktop.
Git Bash Shortcuts
This file contains hidden or 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
#when you want to branch and checkout the same branch in one line => gitbc feature/xyz | |
gbc() { git branch "$@" && git checkout "$@"; } | |
#git status is too much typing | |
gs() { git status; } | |
#git add all is too much typing | |
gaa() { git add -A; } | |
#git push is too much typing | |
gpo() { git push -u origin "$@"; } | |
#git status is too much typing | |
gs() { git status; } | |
#git commit is too much typing | |
gcm() { git commit -m "$@"; } | |
#git checkout master is too much typing | |
gchm() { git checkout master && git pull; } | |
#git add all and merge master in one line (only do this if status checks out) | |
gamm() { gaa && gcm "merge from master"; } | |
#npm run build is too much typing | |
nrb() { npm run build; } | |
#npm run test is too much typing | |
nrt() { npm run test; } | |
#npm start is too much typing | |
ns() { npm start; } | |
#npm run prettier is too much typing | |
np() { npm run prettier; } | |
#when you want to change all extensions in one dir from a => b : swapext css scss | |
swapext(){ | |
for f in *.$1; do | |
mv -- "$f" "${f%.$1}.$2" | |
done | |
} | |
#when you want to change all extensions in a dir and descendent directories from a => b : swapallext /dirname css scss | |
swapallext(){ | |
for file in "$1"/* | |
do | |
if [ ! -d "${file}" ] ; then | |
ext="${file##*.}" | |
if [ "$ext" == "$2" ]; then | |
#echo "css detected" | |
mv -- "$file" "${file%.$2}.$3" | |
fi | |
elif [ "${file}" != "./node_modules" ] ; then | |
#echo "entering recursion with: ${file}" | |
swapallext "${file}" "$2" "$3" | |
fi | |
done | |
} | |
#when you want to mk a directory and enter in one command : mkcd newdirname | |
mkcd (){ | |
mkdir -p "$1" | |
cd "$1" | |
} | |
#when you need a implementation to crawl folders/files : traverse /dirname/ | |
traverse() { | |
for file in "$1"/* | |
do | |
if [ ! -d "${file}" ]; then | |
echo "${file} is a file" | |
elif [ "${file}" != "./node_modules" ] ; then | |
echo "entering recursion with: ${file}" | |
traverse "${file}" | |
fi | |
done | |
} | |
#swap all strings in files from a => b : swapstringinfile /dirname css scss | |
swapstringinfile(){ | |
for file in "$1"/* | |
do | |
if [ ! -d "${file}" ] ; then | |
LC_CTYPE=C && LANG=C && sed -i "" "s/${2}/${3}/g" $file; | |
elif [ "${file}" != "./node_modules" ] ; then | |
swapstringinfile "${file}" "$2" "$3" | |
fi | |
done | |
} | |
#create a react app with typescript and sass with one line : reacttypescriptsass appname | |
reacttypescriptsass(){ | |
npx create-react-app $1 --typescript && cd $1 && npm install node-sass @types/react --save && swapallext . css | |
scss && swapstringinfile . css scss | |
} | |
#get rid of node_modules dirs to avoid drive bloat | |
#find . -name "node_modules" -exec rm -rf '{}' + |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment