Skip to content

Instantly share code, notes, and snippets.

@chfle
Last active August 29, 2021 13:01
Show Gist options
  • Save chfle/1f68da5feee7f3cc76d5f2d9c33198dd to your computer and use it in GitHub Desktop.
Save chfle/1f68da5feee7f3cc76d5f2d9c33198dd to your computer and use it in GitHub Desktop.
My bashrc file for macos and linux
export PATH=$PATH:/home/$USER/chomper/bin
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export PAGER='most'
export LESS_TERMCAP_mb=$'\e[1;32m'
export LESS_TERMCAP_md=$'\e[1;32m'
export LESS_TERMCAP_me=$'\e[0m'
export LESS_TERMCAP_se=$'\e[0m'
export LESS_TERMCAP_so=$'\e[01;33m'
export LESS_TERMCAP_ue=$'\e[0m'
export LESS_TERMCAP_us=$'\e[1;4;31m'
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
# Git
alias gpom="git push origin main"
alias gpuom="git pull origin main"
alias ga="git add ."
# Brew
alias bu="brew update"
alias bi="brew install"
# vim
alias brc="vim ~/.bashrc"
alias prof="vim ~/.profile"
alias vi=vim
alias svi='sudo vi'
alias vis='vim "+set si"'
alias edit='vim'
alias v="vim"
EX=~/.exrc
# create ex and vi file
if [ ! -f $EX ];
then
touch $EX
# then set some variables
echo "\" Vi and Vim settings" >> $EX
echo " " >> $EX
echo "set autoindent" >> $EX
echo "set ruler" >> $EX
echo "set laststatus=2" >> $EX
echo "set relativenumber" >> $EX
echo "set lazyredraw" >> $EX
echo "set showmatch" >> $EX
echo "set smartindent" >> $EX
echo "set incsearch" >> $EX
echo "set hlsearch" >> $EX
echo "set cursorline" >> $EX
echo " " >> $EX
echo "\" Shortcuts" >> $EX
echo "set tabstop=4" >> $EX
echo "set shiftwidth=4" >> $EX
echo "set expandtab" >> $EX
fi
# apt
alias au="sudo apt update"
alias agu="sudo apt-get update"
# dnf
alias sdu="sudo dnf update"
alias sddi="sudo dnf install"
# cd
alias www="cd /var/www"
# common commands
alias c='clear'
alias l="ls"
alias la="ls -la"
alias lah="ls -lah"
alias dual="du -lha"
alias psax="ps -axu"
# if user is not root, pass all commands via sudo #
if [ $UID -ne 0 ]; then
alias reboot='sudo reboot'
alias update='sudo apt-get upgrade'
fi
#grep
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
#ping
# Stop after sending count ECHO_REQUEST packets #
alias ping='ping -c 5'
# Do not wait interval 1 second, go fast #
alias fastping='ping -c 105 -s.2'
#color
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
SUDO_EDITOR=/usr/bin/vim
export SUDO_EDITOR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment