Skip to content

Instantly share code, notes, and snippets.

@john-science
Last active April 9, 2024 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save john-science/f6aa96de49a9cba76d53889db6daad7c to your computer and use it in GitHub Desktop.
Save john-science/f6aa96de49a9cba76d53889db6daad7c to your computer and use it in GitHub Desktop.
A handy .bashrc file.
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# aliases I love
alias l='ls -thal'
alias lh='ls -thal'
alias top='htop'
alias vi='vim'
alias py='/usr/bin/python3.11'
alias unmount='umount'
# aliases I use to fix typos
alias la='ls -thal'
alias lds='ls -thal'
alias lsd='ls -thal'
alias suod='sudo'
# aliases for Git
alias lol='git log --graph --decorate --pretty=oneline --abbrev-commit'
alias push='git push origin $1'
alias pull='git pull origin $1'
alias gitd='git diff --name-only'
alias untracked='git ls-files --others --exclude-standard'
alias meld='git mergetool --tool meld'
alias gclean='git fetch --all && git fetch --prune && git gc --prune=now --aggressive'
# aliases I use for apt
alias apt-up='sudo apt-get update -y;sudo apt-get dist-upgrade -y;sudo apt-get autoremove -y;sudo apt-get autoclean -y'
# fix NumPy threading issue
export OMP_NUM_THREADS=1
export MKL_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1
#
# BEGIN HELPER FUNCTIONS
#
# make it easier to do math right in the shell
function math {
echo $* | bc -l
}
# find the length of a string (you can use quotes)
function strlen {
echo ${#1}
}
# recursively find all files in this folder with a particular ending
function findend {
find . -type f -name \*.${1}
}
# sort lines in a file
function sortfile {
grep -v '^#' ${1} | sort -u
}
# view a CSV in a more human-readable format
function viewcsv {
column -s, -t < ${1} | less -#2 -N -S
}
# repeat commands more easily in Linux
x3() {
for i in `seq 3`; do
$@
done
}
x5() {
for i in `seq 5`; do
$@
done
}
x10() {
for i in `seq 10`; do
$@
done
}
# Set Prompt Styles
force_color_prompt=yes
if [ "$force_color_prompt" = yes ]; then
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
PS1='\u@\h:\W\$ '
fi
unset force_color_prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment