This is what I got in most of my .bashrc files. I collected some snippets over time and abandoned others, so that it doesn't get too bloated.
Last active
April 4, 2019 16:08
-
-
Save bxt/846197 to your computer and use it in GitHub Desktop.
some stuff for .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
# .bashrc commands by bxt | |
# color promt: | |
PS1="\@ \[\033[0;35m\]\u@\\h\[\033[0m\]:\w> " | |
# actually I sometimes use this one (shorter, 24h clock) | |
PS1=" \t \[\033[0;35m\]:\w>\[\033[0m\] " | |
# Change shell apps language to english: | |
export LANG=C | |
export LC_LANG=C | |
# ha ha | |
alias gn8="exit" | |
# check network config | |
alias myip="/sbin/ifconfig" | |
# process-finder | |
alias psf='ps aux | grep -v grep | grep ' | |
# calculator | |
? () { echo "$*" | bc -l; } | |
# avoid duplicate entries in history | |
export HISTCONTROL=ignoredups | |
# save history for multiple terminals | |
shopt -s histappend | |
# make history long | |
export HISTSIZE=1000000 HISTFILESIZE=1000000 | |
# ignore exit commands | |
declare -x HISTIGNORE=exit:gn8 | |
# Share pwd via http on port 8000 | |
webshare () { python -m SimpleHTTPServer $([ -z "$1" ] && echo 8000 || echo $1); } | |
# set my fav editor | |
export EDITOR=vim | |
# colored grep rulz | |
export GREP_OPTIONS='--color=auto' | |
# german greetings | |
if [ `date +%H` -lt 12 ]; then | |
echo "Moin. " | |
else | |
echo "Tach. " | |
fi | |
# remember DOS? ;) | |
alias dir='ls -la' | |
# list size of all files and dirs and sort | |
# very useful if you want to know wherer all your TB are gone... | |
alias imbadu="du -sk ./* | sort -n | awk 'BEGIN{ pref[1]=\"K\"; pref[2]=\"M\"; pref[3]=\"G\";} { total = total + \$1; x = \$1; y = 1; while( x > 1024 ) { x = (x + 1023)/1024; y++; } printf(\"%g%s\t%s\n\",int(x*10)/10,pref[y],\$2); } END { y = 1; while( total > 1024 ) { total = (total + 1023)/1024; y++; } printf(\"Total: %g%s\n\",int(total*10)/10,pref[y]); }'" | |
# Cool History Summerizer | |
historyawk(){ history|awk '{a[$2]++}END{for(i in a){printf"%5d\t%s\n",a[i],i}}'|sort -nr|head; } | |
## https://gist.github.com/87359 | |
# handy find/grep aliases | |
rgrep() { fgrep -niIR "${1}" .; } | |
finame() { find . -iname "*${1}*"; } | |
# produce noise: | |
alias noise="cat /usr/share/icons/*/* > /dev/dsp" | |
## http://techfreaks4u.com/blog/posts/geekist-things-i-ever-did-in-linux/ | |
# coin sound: | |
alias coin='play -q http://store.ukd1.co.uk.s3.amazonaws.com/coin.wav' | |
## https://gist.github.com/769923 | |
# neat git log: | |
alias gitlog='git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short' | |
## http://gitimmersion.com/lab_10.html | |
# Create a new minor semver git tag | |
alias grel='git diff --name-only `git describe --tags --abbrev=0` HEAD && git tag `git describe --tags --abbrev=0 | awk '\''BEGIN {FS="."} {print $1 "." $2 "." ($3+1)}'\''` -m "autotag"' | |
# quickly create file backups | |
bu() { cp -v "$1" "$1".`date +%Y-%m-%d.%H-%M-%S`; } | |
# bundler | |
alias be='bundle exec' | |
# Remove weird macOS files | |
alias grdst='find . -type f -name .DS_Store -delete' | |
# You often need the path set up: | |
export PATH="$HOME/bin:$PATH" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: cd2 is another cool tool I created for bash.