diff --git a/src/config/aliases.sh b/src/config/aliases.sh index 4889236..4b772a4 100755 --- a/src/config/aliases.sh +++ b/src/config/aliases.sh @@ -1,3 +1,6 @@ +# default code editor +export EDITOR="code --wait" + net_checker() { # check connection on first time test=$(curl -Is http://www.google.com | grep -oE 'OK' | head -n 1) @@ -27,21 +30,46 @@ net_checker() { notify-send 'Internet Checker' 'Internet Connection is OK' -i network-wired -u critical } -# Set Vs Code as default code editor -export EDITOR="code --wait" +open-github() { + local github_repo=$(git remote -v | grep -m 1 "origin" | cut -d ':' -f 2 | cut -d '.' -f 1) + + xdg-open "https://github.com/$github_repo" +} + +pid-find() { + ps aux | grep -v 'grep' | grep $1 -m 1 | awk '{print $2}' +} + +r() { + if [ -f 'bin/dev' ] && [ "$1" = "s" ]; then + bin/dev + else + bin/rails $@ + fi +} + +# ==================== GIT ============================== +# shortcode for git status +alias gst="git status" +# use: gpu my-branch +alias gpu="git pull origin" +# use: gps my-branch +alias gps="git push origin" +# run after fixing conflicts +alias gmg="git add . && git merge --continue" +# remove all local branches except master +alias grb='git branch | grep -v "master" | xargs git branch -D' # =================== Ruby on Rails======================= -# run rails command inside project -alias r="bin/rails" # database redo alias rdb_redo="bin/rails db:drop db:create db:migrate" # database teste redo -alias rdb_teste="RAILS_ENV=test bin/rails db:drop db:create db:migrate" +alias rdb_teste="bin/rails db:drop db:create db:migrate RAILS_ENV=test" # =================== Others ============================= # Check if you have internet connection and show notification if any alias has_net=net_checker -alias ip_addr="sudo ip -br -c addr show" -alias ip_public="curl --silent ifconfig.me/ip" +alias mip="ip -c -br a" +alias mipub="curl ifconfig.me/ip"