Skip to content

Instantly share code, notes, and snippets.

@Dragod
Last active May 6, 2021 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dragod/47f2a178a3dcbd63437c5899e813096a to your computer and use it in GitHub Desktop.
Save Dragod/47f2a178a3dcbd63437c5899e813096a to your computer and use it in GitHub Desktop.
2021 .bashrc
green='\e[32m'
blue='\e[34m'
clear='\e[0m'
#Green
GREEN=`tput setaf 2`
# Red
RED='\033[0;31m'
# reset the foreground colour
textreset=$(tput sgr0)
# Color Functions
ColorGreen(){
echo -ne $green$1$clear
}
ColorBlue(){
echo -ne $blue$1$clear
}
alert(){
echo -ne $RED$1$clear
}
# echo -ne $(ColorBlue 'Some text here')
#gnomon, https://github.com/paypal/gnomon
gnomon="| gnomon --medium=5.0 --high=10.0 --ignore-blank --real-time=100"
# npm run
run="npm run"
# Git alias
alias gs='git status '
alias gf='git fetch '
alias ga='git add . '
alias gb='git branch '
alias gb-all='git branch -a'
alias gc='git commit -a -m '
alias pu='git pull '
alias ph='git push '
alias go='git checkout '
alias dev-log='git log --full-history --pretty=oneline --date-order --decorate=full --skip=0 --max-count=100 dev '
# Use git stash and then stash drop to remove every uncommitted change
alias stash='git stash'
# Discard all unstaged changes
alias discard='git checkout -- .'
# List your most recently-used branches
# https://ses4j.github.io/2020/04/01/git-alias-recent-branches/
alias lb='git lb'
# Useful alias
alias list='ls -la '
alias gr='grunt '
# Run server on sdcore folder
alias serve=''${run}' dev'
# Open firefox
alias ff='start firefox'
# Open edge
alias edge='start msedge'
# Open firefox & dev tools on local frontend
alias ff-loc='start firefox -devTools http://localhost:49797/index.aspx'
# Open firefox & dev tools on local admin
alias ff-loc-a='start firefox -devTools http://localhost:49797/admin.aspx'
# Open firefox & dev tools on dev frontend
alias ff-dev='start firefox -devTools https://dev.screendragon.com/index.aspx'
# Open firefox & dev tools on dev
alias ff-dev-a='start firefox -devTools https://dev.screendragon.com/admin.aspx'
# Open edge on localhost forntend
alias edge-loc='start msedge http://localhost:49797/index.aspx'
# Open edge on localhost admin
alias edge-loc-a='start msedge http://localhost:49797/admin.aspx'
# Open edge on dev frotnend
alias edge-dev='start msedge https://dev.screendragon.com/index.aspx'
# Open edge on dev admin
alias edge-dev-a='start msedge https://dev.screendragon.com/admin.aspx'
#Test your internet connection speed and ping using speedtest.net from the CL, https://github.com/sindresorhus/speed-test
alias speed='speed-test --bytes -b'
# Clear bash for real (using "clear" doesn't really work)
alias cls='printf "\033c"'
# Reload bash & print useful information
alias reload='source $HOME/.bash_profile'
# Move to home directory
alias h='cd ~'
# Move to desktop directory
alias dk='cd c:/Users/Fabio/Desktop'
# Move to c: disk
alias dc='cd c:'
# Move to sd-unity directory
alias sd='cd c:/gitrepos/sd-unity-4-0'
# Move to sdcpre directory
alias sdc='cd c:/gitrepos/sdcore/'
# Moving up directories
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# Run vsbuild
alias ms='pwsh ./ms-build.ps1'
# Run openvpn (for this to work you need to open the bash as administrator)
# alias aws='openvpn --config C:/Users/fabio/OpenVPN/config/fabio-awsorig/fabio-awsorig.ovpn'
# alias eu='openvpn --config C:/Users/fabio/OpenVPN/config/fabio-eu/fabio-eu.ovpn'
# Run visual studio build from npm script
#alias vsb="'${run}' vsbuild"
# Workaround to run msbuild in bash
#alias msb="./msb.bat"
# Build alias that run from npm script
# All commands use gnomon to calculate script runnning time
#
alias g-c="${run} grunt:core ${gnomon}"
alias g-cs="${run} grunt:colors ${gnomon}"
alias g-ccs="${run} gr:core-colors ${gnomon}"
alias g-admin="${run} grunt:admin ${gnomon}"
alias g-login="${run} grunt:login ${gnomon}"
alias g-mobile="${run} grunt:mobile ${gnomon}"
alias g-svg="${run}' grunt:svg ${gnomon}"
alias tsw="${run} typescript:watch -w"
alias g-all="${run} build:complete ${gnomon}"
alias g-cc="${run} build:cc ${gnomon}"
alias roll='cd C:/gitrepos/sdcore && npm run build && cp C:/gitrepos/sdcore/dist/sdcore.min.js C:/gitrepos/sd-unity-4-0/sdcore && printf "\nsdcore.min.js copied to unity. \n\nDone.\n"'
alias restore='.\nuget restore'
# Specificity for css alias, https://github.com/keeganstreet/specificity. npm install -g specificity. Example: specificity "ul#nav li.active a"
alias spec='specificity'
# Useful alias for misspelling git
alias got='git '
alias get='git '
# Npm list just the packages we have installed globally along with their version numbers.
alias npm-list='npm list -g --depth=0'
#alias auto='source start-node-build.sh'
# Listen radio
function r()
{
if [ "$1" ]; then
eval "npx radio-cli --$1"
else
echo -e -ne $(alert 'Radio station not found. Exit the script...')
exit
fi
}
# Function to Add, commit and push at the same time
function commit-and-push() {
git add .
git commit -a -m "$1"
git push
}
alias cap='commit-and-push'
# When switching to a new branch, remember to track origin
# Use: type "f-branch" in the console
function f-branch()
{
printf "\n${GREEN} New feature branch to track...\n\n"
read -p "Branch name: " branch
if [[ -z "$branch" ]]; then
printf '%s\n' "No branch entered, will now exit..."
return
else
eval "git checkout --track origin/$branch"
fi
}
# Alias "core" for core css build.
# Alias "c skinName" for skin build.
# Alias "cc skinName" for core and skin build.
# Alias "dev skinName" for complete build without postccs.
# Alias "prod skinName" for complete build & postccs.
# Alias "admin" for admin build.
# Alias "mobile" to build mobile.
# Alias "mc skinName" for mobile and skin css. Ex: mc ioc"
# Alias "login" to build login page.
# Alias "svg" to build svg.
# Alias "post" to build postcss.
# Compile core style with node
alias core="node build -c"
# Compile skin style with node
function skin()
{
if [ "$1" ]; then
eval "node build -s $1"
else
echo -e -ne $(alert 'You did not pass any skin so it will build the default skin: amazon-site-lite. To pass a different skin name use: "c skinName"')
eval "node build -s amazon-site-lite"
fi
}
alias c=skin
# Compile core & skin style with node
function core-colors()
{
if [ "$1" ]; then
eval "node build --cc -s $1"
else
echo -e -ne $(alert 'You did not pass any argument so it will build the default skin: amazon-site-lite. To pass a skin name use: "cc skinName"')
eval "node build --cc -s amazon-site-lite"
fi
}
alias cc=core-colors
function mobile-colors()
{
if [ "$1" ]; then
eval "node build -m && node build -s $1"
else
echo -e -ne $(alert 'You did not pass any argument so it will build the default skin: amazon-site-lite. To pass a skin name use: "mc skinName"')
eval "node build -m && node build -s amazon-site-lite"
fi
}
alias mc=mobile-colors
function dev()
{
if [ "$1" ]; then
eval "node build -d && node build -s $1"
else
echo -e -ne $(alert 'You did not pass any argument so it will build the default skin: amazon-site-lite. To pass a skin name use: "mc skinName"')
eval "node build -n && node build -s amazon-site-lite"
fi
}
alias dev=dev
function production()
{
if [ "$1" ]; then
eval "node build -p && node build -s $1"
else
echo -e -ne $(alert 'You did not pass any argument so it will build the default skin: amazon-site-lite. To pass a skin name use: "dev skinName"')
eval "node build -f && node build -s amazon-site-lite"
fi
}
alias prod=production
alias mobile="node build -m"
alias admin="node build --ac"
alias login="node build -l"
alias svg="node build --svg"
alias post="node build --postcss"
#git switch to an existing branch
function gck()
{
printf "${GREEN}Git switch branch...\n\n"
read -p "Branch name: " branch
if [[ -z "$branch" ]]; then
printf '%s\n' "No branch entered, will now exit..."
return
else
eval "git checkout $branch"
fi
}
# Create new feature branch from sd-unity-4-0 dev branch
function createBranchFromDev()
{
if [ "$1" ]; then
printf "\n\rCreating feature core branch: sd-feature-core-$1-1 from \"dev\" branch\n\r"
eval "git checkout dev"
eval "git pull"
eval "git checkout -b sd-feature-core-$1-1 dev"
eval "git push --set-upstream origin sd-feature-core-$1-1"
printf "\n\rSuccess! Created feature core branch: sd-feature-core-$1-1 from \"dev\" branch\n\r"
else
echo "Error in creating the feature branch please try again..."
fi
}
alias feature=createBranchFromDev
# Delete a feature branch from sd-unity-4-0
# It does ask for confirmation before permanent deletion
function deleteFeature(){
if [ "$1" ]; then
# Ask for branch deletion confirmation
echo #space
echo -ne $(alert "- Are you sure you want to PERMANENTLY DELETE the feature core branch: \"sd-feature-core-$1-1\" ? (y,yes or n,no): ")
read yesorno
if [ "$yesorno" = yes ] || [ "$yesorno" = y ] ; then
echo #space
# Can't delete a branch while you are actively on it, so need to switch on dev
eval "git checkout dev"
# Delete branch locally
eval "git branch -d sd-feature-core-$1-1"
# Delete branch from remote
eval "git push --delete origin sd-feature-core-$1-1"
# Need git fetch to update branch deletion
eval "git fetch -p"
# Try to checkout deleted branch, should return a pathspec error if branch was deleted
printf "\n\r If git return a pathspec error below, it means the feature branch as been deleted correctly.\n\r"
eval "git checkout sd-feature-core-$1-1"
elif [ "$yesorno" = no ] || [ "$yesorno" = n ] ; then
printf "\n\rFeature core branch: \"sd-feature-core-$1-1\" was NOT DELETED\n\r"
printf "\n\rScript will now exit...\n\r"
else
printf "\n\rNo vailid answer, script will now exit...\n\r"
fi
else
printf "\n\rYou need to pass a feature branch number.\n\r"
printf "\n\rEx: \"deleteFeature 55432\" witch will be converted to \"sd-feature-core-55432-1\"\n\r"
printf "\n\rScript will now exit...\n\r"
fi
}
function unity-builds()
{
# Define functions costant text
CORE="Build core css. Ex: core"
COLORS="Build skin css. Ex: c ioc"
CORECOLORS="Build core and skin css. Ex: cc ioc"
MOBILECOLORS="Build mobile and skin css. Ex: mc ioc"
MOBILE="Build mobile core css."
DEV="Build complete without postcss. Ex: dev ioc"
ADMIN="Build admin css."
LOGIN="Build login page css."
SVG="Build svg sprite."
PRODUCTION="Build complete with postcss. Ex: prod ioc"
POSTCSS="Build postcss"
# GCORE="Build css core."
# GCOLORS="Build css skin colors. Ex: cs ioc"
# GCORECOLORS="Build core & skin colors. Ex: ccs ioc"
# GADMIN="Build css admin."
# GLOGIN="Build css login page."
# GSVG="Build svg sprite."
# GALL="Complete build"
printf "\n${GREEN}Node-sass builds:\n\n"
printf "${GREEN}core${textreset} \"${CORE}\"\n"
printf "${GREEN}c \`skin-name\`${textreset} \"${COLORS}\"\n"
printf "${GREEN}cc \`skin-name\`${textreset} \"${CORECOLORS}\"\n"
printf "${GREEN}dev \`skin-name\`${textreset} \"${DEV}\"\n"
printf "${GREEN}prod \`skin-name\`${textreset} \"${PRODUCTION}\"\n"
printf "${GREEN}admin${textreset} \"${ADMIN}\"\n"
printf "${GREEN}mobile${textreset} \"${MOBILE}\"\n"
printf "${GREEN}mc \`skin-name\`${textreset} \"${MOBILECOLORS}\"\n"
printf "${GREEN}login${textreset} \"${LOGIN}\"\n"
printf "${GREEN}svg${textreset} \"${SVG}\"\n"
printf "${GREEN}post${textreset} \"${POSTCSS}\"\n"
}
alias unity=unity-builds
function sdcore-builds()
{
# Define functions costant text
SERVE="Run sdcore locally on localhost:6060."
ROLL="Run & copy sdcore js to unity"
printf "\n${GREEN}Sdcore builds:\n\n"
printf "${GREEN}serve${textreset} \"${SERVE}\"\n"
printf "${GREEN}roll${textreset} \"${ROLL}\"\n"
}
alias sdcore=sdcore-builds
printf "\n${GREEN}List of commands:\n\n"
printf "${textreset}* Type ${GREEN}'unity'${textreset} for a list of unity-40 build\n\n"
printf "* Type ${GREEN}'sdcore'${textreset} for a list of vue components build\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment