Last active
July 24, 2019 09:15
-
-
Save Dragod/3e2da47d67f19a67bce73e7f838799b6 to your computer and use it in GitHub Desktop.
Personalized .bashrc -- path: C:\Users\fabio\.bashrc
This file contains 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
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac | |
# Path to the bash it configuration | |
export BASH_IT="/c/Users/fabio/.bash_it" | |
# Lock and Load a custom theme file. | |
# Leave empty to disable theming. | |
# location /.bash_it/themes/ | |
export BASH_IT_THEME='fabio' | |
# (Advanced): Change this to the name of your remote repo if you | |
# cloned bash-it with a remote other than origin such as `bash-it`. | |
# export BASH_IT_REMOTE='bash-it' | |
# Your place for hosting Git repos. I use this for private repos. | |
export GIT_HOSTING='git@git.domain.com' | |
# Don't check mail when opening terminal. | |
unset MAILCHECK | |
# Change this to your console based IRC client of choice. | |
export IRC_CLIENT='irssi' | |
# Set this to the command you use for todo.txt-cli | |
export TODO="t" | |
# Set this to false to turn off version control status checking within the prompt for all themes | |
export SCM_CHECK=true | |
# Set Xterm/screen/Tmux title with only a short hostname. | |
# Uncomment this (or set SHORT_HOSTNAME to something else), | |
# Will otherwise fall back on $HOSTNAME. | |
#export SHORT_HOSTNAME=$(hostname -s) | |
# Set Xterm/screen/Tmux title with only a short username. | |
# Uncomment this (or set SHORT_USER to something else), | |
# Will otherwise fall back on $USER. | |
#export SHORT_USER=${USER:0:8} | |
# Set Xterm/screen/Tmux title with shortened command and directory. | |
# Uncomment this to set. | |
#export SHORT_TERM_LINE=true | |
# Set vcprompt executable path for scm advance info in prompt (demula theme) | |
# https://github.com/djl/vcprompt | |
#export VCPROMPT_EXECUTABLE=~/.vcprompt/bin/vcprompt | |
# (Advanced): Uncomment this to make Bash-it reload itself automatically | |
# after enabling or disabling aliases, plugins, and completions. | |
# export BASH_IT_AUTOMATIC_RELOAD_AFTER_CONFIG_CHANGE=1 | |
# Uncomment this to make Bash-it create alias reload. | |
# export BASH_IT_RELOAD_LEGACY=1 | |
# Load Bash It | |
source "$BASH_IT"/bash_it.sh | |
# Personal stuff for .bashrc | |
# don't put duplicate lines or lines starting with space in the history. | |
# See bash(1) for more options | |
HISTCONTROL=ignoreboth | |
# append to the history file, don't overwrite it | |
shopt -s histappend | |
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | |
HISTSIZE=1000 | |
HISTFILESIZE=2000 | |
# check the window size after each command and, if necessary, | |
# update the values of LINES and COLUMNS. | |
shopt -s checkwinsize | |
#Green | |
GREEN=`tput setaf 2` | |
# Red | |
RED='\033[0;31m' | |
# 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 ' | |
alias aws='amazon-site-lite' | |
# Use git stash and then stash drop to remove every uncommitted change | |
alias stash='git stash' | |
# Useful alias | |
alias list='ls -la ' | |
alias gr='grunt ' | |
# Load Sass build script in main repo folder | |
alias sassb='source grunt.sh' | |
# open file at specific line and column <file:line[:character]>, ex: code --goto package.json:10:5 | |
alias goto='code --goto' | |
# Run server on sdcore folder | |
alias serve='npm run dev' | |
# 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 firefox & dev tools on kpath40 | |
alias ff-k='start firefox -devTools https://kelloggrelease40.screendragon.com/' | |
# Open chrome on localhost forntend | |
alias ch-loc='start chrome http://localhost:49797/index.aspx' | |
# Open chrome on localhost admin | |
alias ch-loc-a='start chrome http://localhost:49797/admin.aspx' | |
# Open chrome on dev frotnend | |
alias ch-dev='start chrome https://dev.screendragon.com/index.aspx' | |
# Open chrome on dev admin | |
alias ch-dev-a='start chrome 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' | |
# S Provider/Tag Autocompletion https://github.com/zquestz/s | |
if [ -f C:/Users/fabio/go/src/github.com/zquestz/s/autocomplete/s-completion.bash ]; then | |
. C:/Users/fabio/go/src/github.com/zquestz/s/autocomplete/s-completion.bash | |
fi | |
# Using scoop in bash, https://github.com/lukesampson/scoop/wiki | |
function scoop() { powershell -ex unrestricted scoop.ps1 "$@" ;} && export -f scoop | |
# youtube search | |
alias yt='s -p youtube' | |
# stackoverflow search | |
alias so='s -p stackoverflow' | |
# Move to home directory | |
alias h='cd ~' | |
# Move to desktop directory | |
alias dk='cd c:/Users/Fabio/Desktop' | |
# Move to c: disk | |
alias c='cd c:' | |
# Move to sd-unity directory | |
alias sd='cd c:/gitrepos/sd-unity-4-0' | |
# Move to sdcpre directory | |
alias sdcore='cd c:/gitrepos/sdcore/' | |
# Moving up directories | |
alias ..='cd ..' | |
alias ...='cd ../..' | |
alias ....='cd ../../..' | |
alias .....='cd ../../../..' | |
# 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="npm run vsbuild" | |
# Grunt alias that run from npm script | |
alias core='npm run core' | |
alias admin='npm run admin' | |
alias login='npm run login' | |
alias mobile='npm run mobile' | |
alias svg='npm run svg' | |
alias tsw='npm run tsc -w' | |
alias colors='npm run colors' | |
alias core-colors='npm run core-colors' | |
alias all='npm run build:complete' | |
alias cc='npm run build:cc' | |
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"' | |
# typescript watch | |
alias tsw='tsc -w' | |
# 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 ' | |
#Git branches description "npm install git-br -g": https://github.com/bahmutov/git-branches#adding-to-bash_profile | |
alias br='git br' | |
# Add branch description | |
alias br-desc='git branch --edit-description' | |
#To enable bash tab auto-completion for grunt, add the following line to your ~/.bashrc file: | |
eval "$(grunt --completion=bash)" | |
# Track my commits (all) | |
alias my-log='git log --author="fabio@screendragon.com"' | |
# Npm list just the packages we have installed along with their version numbers. | |
alias npm-list='npm list -g --depth=0' | |
# List outdated npm packages | |
alias outdated='npm outdated' | |
# Some alias from https://www.quora.com/What-is-the-most-useful-bash-script-that-you-have-ever-written | |
alias gog="git log --abbrev-commit --name-status --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'" | |
alias gml="git log --stat --color --decorate --all --oneline" | |
#alias ccat="source-highlight --out-format=esc256 -o STDOUT -i" | |
ifind () { | |
find . -iname "*$1*" | |
} | |
ff() { fn "$1" "-type f" ; } # ditto, regular files only | |
fd() { fn "$1" "-type d" ; } | |
# 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' | |
# get commits by name or email | |
function get-commit() | |
{ | |
printf "\n${GREEN} Check commits by person name...\n\n" | |
read -p "Person name: " name | |
if [[ -z "$name" ]]; then | |
printf '%s\n' "No name entered, will now exit..." | |
return | |
else | |
eval 'git log --author="$name"' | |
fi | |
} | |
alias gct='get-commit' | |
# get commits by name or email, pretty version | |
function get-commit-pretty() | |
{ | |
printf "\n${GREEN} Check commits by person name...\n\n" | |
read -p "Person name: " name | |
if [[ -z "$name" ]]; then | |
printf '%s\n' "No name entered, will now exit..." | |
return | |
else | |
eval 'git log --author="$name" --pretty=format:"%h - %an, %ar : %s"' | |
fi | |
} | |
alias gcp='get-commit-pretty' | |
# Show n number of logs for x user in colour by adding this little snippet in your .bashrc file. | |
# https://stackoverflow.com/questions/4259996/how-can-i-view-a-git-log-of-just-one-users-commits | |
gitlog() | |
{ | |
if [ "$1" ] && [ "$2" ]; then | |
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order -n "$1" --author="$2" | |
elif [ "$1" ]; then | |
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order -n "$1" | |
else | |
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order | |
fi | |
} | |
alias l=gitlog | |
# Find branches the commit is on | |
# https://stackoverflow.com/questions/2706797/finding-what-branch-a-git-commit-came-from | |
find-commit() | |
{ | |
if [ "$1" ]; then | |
git branch --contains "$1" | |
else | |
echo "exit.." | |
fi | |
} | |
alias fc=find-commit | |
# Search the reflogs | |
# https://stackoverflow.com/questions/2706797/finding-what-branch-a-git-commit-came-from | |
s-reflogs() | |
{ | |
if [ "$1" ]; then | |
git reflog show --all | grep "$1" | |
else | |
echo "exit.." | |
fi | |
} | |
alias sr=s-reflogs | |
#get commit branch name by it's ref Ex: git name-rev 651ad3a - remotes/origin/test-branch | |
# git name-rev <SHA> | |
# https://stackoverflow.com/questions/2706797/finding-what-branch-a-git-commit-came-from | |
get-commit-branch() | |
{ | |
if [ "$1" ]; then | |
git name-rev "$1" | |
else | |
echo "exit.." | |
fi | |
} | |
alias gcb=get-commit-branch | |
# 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 | |
} | |
# Serch with bash using grep | |
function s-search() | |
{ | |
printf "\n${GREEN} Git search using grep...\n\n" | |
read -p "Search: " word | |
read -p "file extension (ex: css): " extension | |
if [[ -z "$word" ]] && [[-z "$extension"]]; then | |
printf '%s\n' "Nothing to search, will now exit..." | |
return | |
else | |
eval "git grep -in "$word" -- *.$extension" | |
fi | |
} | |
# Show available git alias | |
function git-alias() | |
{ | |
printf "\nGIT Aliases\n\n" | |
printf "gs --> git status\n\n" | |
printf "gf --> git fetch\n\n" | |
printf "ga --> git add .\n\n" | |
printf "gc --> git commit\n\n" | |
printf "pu --> git pull\n\n" | |
printf "ph --> git push\n\n" | |
printf "go --> git checkout\n\n" | |
printf "gb --> git branch\n\n" | |
printf "gb-all --> git show all branches\n\n" | |
printf "dev-log --> git trak last 100 commit on dev branch and draw a pretty output\n\n" | |
printf "\n" | |
} | |
# Show available npm alias | |
function npm-alias() | |
{ | |
printf "\nNPM Aliases\n\n" | |
printf "core --> npm run core\n\n" | |
printf "admin --> npm run admin\n\n" | |
printf "login --> npm run login\n\n" | |
printf "mobile --> npm run mobile\n\n" | |
printf "svg --> npm run svg\n\n" | |
printf "tsw --> npm run tsc -w\n\n" | |
printf "colors --> npm run colors\n\n" | |
printf "core-colors --> npm run core-colors\n\n" | |
printf "vsb --> npm run vsbuild\n\n" | |
printf "\n" | |
} | |
# alias used only in C:gitrepos/sdcore. It runs copy.sh | |
alias jcopy='./copy.sh' | |
#A bash script called up so that if I'm in /a/very/deeply/nested/path/somewhere and I want to go "up" N directories, I can type "up N" or "back N" | |
function up( ) | |
{ | |
LIMIT=$1 | |
P=$PWD | |
for ((i=1; i <= LIMIT; i++)) | |
do | |
P=$P/.. | |
done | |
cd $P | |
export MPWD=$P | |
} | |
function back( ) | |
{ | |
LIMIT=$1 | |
P=$MPWD | |
for ((i=1; i <= LIMIT; i++)) | |
do | |
P=${P%/..} | |
done | |
cd $P | |
export MPWD=$P | |
} | |
# Find a file with a pattern in name Example: ff index.aspx or index | |
function ff() { find . -type f -iname '*'"$*"'*' -ls ; } | |
#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 | |
} | |
function copyjs() | |
{ | |
cd C:/gitrepos/sdcore/dist | |
for f in *.js | |
do | |
cp -v "$f" C:/Users/fabio/Documents/${f%.js}.js | |
done | |
} | |
# Build css colors from unity and copy it over to sdcore doc | |
# copyColors() | |
# { | |
# if [ "$1" ]; then | |
# eval "grunt colors-1 --skin=$1" && cd C:/gitrepos/sd-unity-4-0/assets/$1/css && cp $1.css skin.css && | |
# cp -i C:/gitrepos/sd-unity-4-0/assets/$1/css/skin.css C:/gitrepos/sdcore/docs/css | |
# else | |
# printf "Please add a skin name. Ex: cpcolors ioc" | |
# fi | |
# } | |
# alias cpcolors=copyColors | |
# Build css colors from unity and copy it over to sdcore doc | |
copyColors() { | |
printf "\n################ [${light_purple}Build css colors from unity and copy it over to sdcore doc] ################\n\n" | |
eval 'grunt doc-colors' && cp -i C:/gitrepos/sd-unity-4-0/assets/sdcore/css/skin.css C:/gitrepos/sdcore/docs/css | |
printf "\n###############################################################\n" | |
} | |
alias cpcolors=copyColors | |
# Build css core from unity and copy it over to sdcore doc | |
copyCore() { | |
printf "\n################ [${light_purple}Build css core from unity and copy it over to sdcore doc] ################\n\n" | |
eval 'grunt doc-core' && cp -i C:/gitrepos/sd-unity-4-0/assets/sdcore/css/app.css C:/gitrepos/sdcore/docs/css | |
printf "\n###############################################################\n" | |
} | |
alias cpcore=copyCore | |
function help() | |
{ | |
# Define functions costant text | |
SPEED="Test your internet connection speed and ping" | |
YT="Youtube search. Example: 'yt firefox'" | |
SO="Stackoverflow search. Example: 'so visual studio code'" | |
H="Move to home directory" | |
DK="Move to desktop directory" | |
C="Move to c: disk" | |
SD="Move to sd-unity directory" | |
AWS="Run openvpn on aws (for this to work you need to open the bash as administrator)" | |
EU="Run openvpn on eu (for this to work you need to open the bash as administrator)" | |
VSB="Run visual studio build from npm script" | |
TSW="typescript watch" | |
SPEC="Specificity for css alias, Ex: specificity 'ul#nav li.active a'" | |
BR="Show all branch and description if any available" | |
BRDESC="Add description to current branch" | |
MYLOG="Track my commits (all)" | |
NPMLIST="Npm list just the packages we have installed along with their version numbers" | |
OUTDATED="List outdated npm packages" | |
GCT="Get commits by name or email" | |
GCP="Get commits by name or email, pretty version" | |
L="Show n number of logs for x user in colour. Example: 'l 10', 'l 20 fabio'" | |
FC="Find branches the commit is on. Example: 'fc 3f65cc2d545b14a08f59117f6c27ecce47e916f5'" | |
SR="Search the reflogs. How to use: sr <SHA>. Example: 'sr 3f65cc2d'" | |
GCB="Get commit branch name by it's ref Example: 'gcb 3f65cc2d'" | |
UP="Go up N directories. Example: up 2" | |
BACK="Go back N directories. Example: back 2" | |
FBRANCH="Switching to a new branch to track origin" | |
GCK="Switching to existing branch, already tracked" | |
CAP="Add,commit with comment & push in one line. Example: 'cap \"bug fix #34455\"'" | |
ROLL="Rollup build, it builds vue component for unity and copy the sdcore.min.js to sdcore folder" | |
CPCOLORS="Build css colors from unity and copy it over to sdcore doc" | |
CPCORE="Build css core from unity and copy it over to sdcore doc" | |
printf "\n${GREEN}List of available commands:\n\n" | |
printf "\- speed --> ${SPEED}\n" | |
printf "\- yt --> ${YT}\n" | |
printf "\- so --> ${SO}\n" | |
printf "\- h --> ${H}\n" | |
printf "\- dk --> ${DK}\n" | |
printf "\- c --> ${C}\n" | |
printf "\- sd --> ${SD}\n" | |
printf "\- aws --> ${AWS}\n" | |
printf "\- eu --> ${EU}\n" | |
printf "\- vsb --> ${VSB}\n" | |
printf "\- tsw --> ${TSW}\n" | |
printf "\- spec --> ${SPEC}\n" | |
printf "\- br --> ${BR}\n" | |
printf "\- br-desc --> ${BRDESC}\n" | |
printf "\- my-log --> ${MYLOG}\n" | |
printf "\- npm-list --> ${NPMLIST}\n" | |
printf "\- outdated --> ${OUTDATED}\n" | |
printf "\- gct --> ${GCT}\n" | |
printf "\- gcp --> ${GCP}\n" | |
printf "\- l --> ${L}\n" | |
printf "\- fc --> ${FC}\n" | |
printf "\- sr --> ${SR}\n" | |
printf "\- gcb --> ${GCB}\n" | |
printf "\- up --> ${UP}\n" | |
printf "\- back --> ${BACK}\n" | |
printf "\- f-branch --> ${FBRANCH}\n" | |
printf "\- gck --> ${GCK}\n" | |
printf "\- cap --> ${CAP}\n" | |
printf "\- roll --> ${ROLL}\n" | |
printf "\- cpcolors --> ${CPCOLORS}\n" | |
printf "\- cpcore --> ${CPCORE}\n" | |
} | |
# Clear bash for real (using "clear" doesn't really work) | |
alias cls='printf "\033c"' | |
# Load ssh and save credentials on windows | |
# https://help.github.com/articles/working-with-ssh-key-passphrases/#auto-launching-ssh-agent-on-git-for-windows | |
env=~/.ssh/agent.env | |
agent_load_env () { test -f "$env" && . "$env" >| /dev/null ; } | |
agent_start () { | |
(umask 077; ssh-agent >| "$env") | |
. "$env" >| /dev/null ; } | |
agent_load_env | |
# agent_run_state: 0=agent running w/ key; 1=agent w/o key; 2= agent not running | |
agent_run_state=$(ssh-add -l >| /dev/null 2>&1; echo $?) | |
if [ ! "$SSH_AUTH_SOCK" ] || [ $agent_run_state = 2 ]; then | |
agent_start | |
ssh-add | |
elif [ "$SSH_AUTH_SOCK" ] && [ $agent_run_state = 1 ]; then | |
ssh-add | |
fi | |
unset env | |
# Load bash on working folder | |
cd C:/gitrepos/sd-unity-4-0 | |
# Reload bash & print useful information | |
alias reload='source $HOME/.bash_profile' | |
# echo " | |
# Screendragon Fight Bugs | | | |
# \_V_// | |
# \/=|=\/ | |
# [=v=] | |
# __\___/_____ | |
# /..[ _____ ] | |
# /_ [ [ M /] ] | |
# /../.[ [ M /@] ] | |
# <-->[_[ [M /@/] ] | |
# /../ [.[ [ /@/ ] ] | |
# _________________]\ /__/ [_[ [/@/ C] ] | |
# <_________________>>0---] [=\ \@/ C / / | |
# ___ ___ ]/000o /__\ \ C / / | |
# \ / /....\ \_/ / | |
# ....\||/.... [___/=\___/ | |
# . . . . [...] [...] | |
# . .. . [___/ \___] | |
# . 0 .. 0 . <---> <---> | |
# /\/\. . . ./\/\ [..] [..] | |
# / / / .../| |\... \ \ \ _[__] [__]_ | |
# / / / \/ \ \ \ [____> <____] | |
# " | |
# printf "\- SSH ready\n" | |
# printf "\- Aliases ready, type: git-alias or npm-alias for help \n" | |
# printf "\- Functions ready (f-branch, gck, s-search)\n" | |
printf "\- Type 'help' for a list of commands\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To load .bashrc on Windows just add .bashrc file under the user folder Ex: C:\Users\fabio.bashrc