Skip to content

Instantly share code, notes, and snippets.

@ikendoit
Created January 19, 2022 22:04
Show Gist options
  • Save ikendoit/2a3eca0dd9db27203d939cc477e28b62 to your computer and use it in GitHub Desktop.
Save ikendoit/2a3eca0dd9db27203d939cc477e28b62 to your computer and use it in GitHub Desktop.
Lab-bash-rc-2022-01-19
# 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
# 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
# colored GCC warnings and errors
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# Tool: quick going up of directories, example: `up 4` => Go up 4 directory level
function goUpDirectories() {
numOfDirs=''
unit='../'
for i in $(seq 1 $1)
do
numOfDirs="$numOfDirs$unit"
done
cd $numOfDirs
}
alias up='goUpDirectories'
# Tool: Overwrite pushd/popd, they are useless across tmux panes
alias pushd='echo `pwd` >> ~/.directory_temp_stores'
alias popd='cd `cat ~/.directory_temp_stores | head -1`; sed -i "1d" ~/.directory_temp_stores'
function cddToIt() {
cd `cat ~/.directory_temp_stores | head -$1 | tail -1`
}
alias cdd='cddToIt'
alias listd='cat -n ~/.directory_temp_stores'
alias cleard='truncate -s 0 ~/.directory_temp_stores'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment