Last active
June 20, 2024 16:18
-
-
Save sudogem/ac3667637ebc3b7c907d76b5f46f5209 to your computer and use it in GitHub Desktop.
Create a .bashrc file(if not exist) using the command: $ vi ~/.bashrc then update it. Once updated we run this command: $ source ~/.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
## Add git branch name in Terminal | |
force_color_prompt=yes | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
## export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] >\n$ " | |
export PS1="${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\033[33m\]\$(parse_git_branch)\[\033[00m\] >\n$ " | |
# Git shortcuts | |
## Usage: gl -n 100 | |
function gitlog() { | |
arg1=${1:-10} | |
git log -n $arg1 --pretty=format:'%Cgreen%h%Creset%x09%C(cyan)%an%Creset%x09%C(black bold)%ad%Creset%x09%s' | |
} | |
alias gitlogtree="git log -n 10 --graph --decorate -30 --all --date-order --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%C(cyan)%h%Creset %C(black bold)%ad%Creset%C(auto)%d %s'" | |
##### alias gitlog="git log -n 10 --pretty=format:'%Cgreen%h%Creset%x09%C(cyan)%an%Creset%x09%C(black bold)%ad%Creset%x09%s'" | |
alias gl='gitlog' | |
alias c='git cola' | |
alias gs='git status' | |
alias gf='git fetch && git pull --rebase' | |
alias o='git remote show origin' | |
## Clear the screen | |
alias cls='clear;clear' | |
# Rails environments | |
export DOCKER_RAILS_MYSQL_HOST=172.17.0.2 | |
export DOCKER_RAILS_MYSQL_PORT=3306 | |
export DOCKER_RAILS_MYSQL_USER=root | |
export DOCKER_RAILS_MYSQL_PASW=webdevel | |
export DOCKER_RAILS_MYSQL_DB=railsBookDB | |
## Automatic run: On cd command it will check .ruby-version file and then run uru auto | |
cd() { | |
if builtin cd ${1:+"$@"} && [ -e .ruby-version ]; then | |
uru auto | |
fi | |
} | |
## Remove log files inside the log/ folder. We should run this in the root of your application. | |
## Example usage: rmlog && npm start | |
function rmlog() { | |
# <app-root> / log | |
# check if log folder is exist. | |
if [ -d "log" ] | |
then | |
echo "[rmlog()] log folder found!" | |
rm -rf *.* | |
else | |
echo "[rmlog()] log folder does not exist." | |
fi | |
} | |
## Export the node .env environment variables. We should run this in the roo app where .env resides. | |
## Example usage: myenv && npm start | |
function myenv() { | |
echo "=========================================" | |
echo " " | |
echo ".env variables successfully loaded!! " | |
echo " " | |
echo "=========================================" | |
set -o allexport; source .env; set +o allexport | |
} | |
function rand() { | |
cat /dev/urandom | base64 | head -n 1 |tr -dc '[:alpha:]' |cut -c -8 | |
} | |
## Github multiple accounts | |
## $ cat ~/.ssh/config | |
## Host *github.com | |
## User git | |
## IdentityFile ~/.ssh/company_id_rsa | |
## | |
## Host *github-sudogem | |
## Hostname github.com | |
## User git | |
## IdentityFile ~/.ssh/sudogem_id_rsa.pub | |
## Github login | |
# For Windows | |
function github_autologin() { | |
eval $(ssh-agent) | |
ssh-add "/c/Users/My Company/.ssh/sudogem_id_rsa" | |
} | |
github_autologin | |
# For Ubuntu | |
function github_autologin_sudogem() { | |
eval $(ssh-agent) | |
ssh-add ~/.ssh/id_rsa_sudogem | |
} | |
github_autologin_sudogem | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then run this command to execute the bashrc file in the current terminal: $ source ~/.bashrc