Skip to content

Commit

Permalink
update rails aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
wilfison committed Mar 5, 2023
1 parent 1db5578 commit a29be01
Showing 1 changed file with 35 additions and 7 deletions.
42 changes: 35 additions & 7 deletions src/config/aliases.sh
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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"

0 comments on commit a29be01

Please sign in to comment.