Last active
October 16, 2016 17:27
-
-
Save adamjedlicka/d053536063d01cd9ed48 to your computer and use it in GitHub Desktop.
BASH config files
This file contains hidden or 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
#!/bin/bash | |
function gitPrettyLog() { | |
HASH="%C(yellow)%h%C(reset)" | |
TIME="%C(green)%ar%C(reset)" | |
AUTHOR="%C(bold blue)%an%C(reset)" | |
REFS="%C(red)%d%C(reset)" | |
SUBJECT="%s" | |
FORMAT="$HASH{$TIME{$AUTHOR{$REFS $SUBJECT" | |
git log --pretty="tformat:$FORMAT" $* | | |
column -t -s "{" | | |
less -FXRS | |
} |
This file contains hidden or 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
#!/bin/bash | |
autoupdate=true | |
export GOPATH=~/dev/go | |
export GOBIN=$GOPATH/bin | |
# edited path | |
export PATH=$PATH:$GOBIN:~/bin | |
# load util scripts | |
[ -r ~/.bash_utils ] && source ~/.bash_utils | |
[ -r ~/.git-prompt.sh ] && source ~/.git-prompt.sh | |
_uname='\[\033[38;5;242m\]\u' | |
_at='\[\033[38;5;203m\]@' | |
_host='\[\033[38;5;242m\]\h' | |
_path='\[\033[38;5;15m\]:\[\033[38;5;203m\]$(__shortpath "\w" 20)' | |
_cmd='\[\033[38;5;15m\] $ ' | |
_git='\[\033[38;5;242m\]$(__git_ps1)' | |
# show machine name when connected over ssh | |
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then | |
export PS1=$_uname$_at$_host$_path$_cmd | |
else | |
export PS1=$_uname$_path$_git$_cmd | |
fi | |
# ShortPath function | |
function __shortpath() { | |
if [[ ${#1} -gt $2 ]]; then | |
len=$2+3 | |
echo "..."${1: -$len} | |
else | |
echo $1 | |
fi | |
} | |
# sets terminal's header to current direcotry | |
export PROMPT_COMMAND='echo -ne "\033]0;${PWD}\007"' | |
# skip duplicates in BASH history (key up) | |
export HISTCONTROL=ignoreboth:erasedups | |
# enable color support of ls, grep, ... | |
if [ -x /usr/bin/dircolors ]; then | |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | |
alias ls='ls --color=auto' | |
alias grep='grep --color=auto' | |
fi | |
# aliases | |
alias 'll'='ls -alF' | |
alias 'la'='ls -A' | |
alias 'l'='ls -CF' | |
alias 'please'='sudo $(history -p !!)' | |
# Add an "alert" alias for long running commands. Use like so: | |
# sleep 10; alert | |
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" \ | |
"Alert" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' | |
# enable programmable completion features | |
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then | |
. /etc/bash_completion | |
fi | |
# colorful man pages | |
function man() { | |
env \ | |
LESS_TERMCAP_mb=$(printf "\e[1;31m") \ | |
LESS_TERMCAP_md=$(printf "\e[1;31m") \ | |
LESS_TERMCAP_me=$(printf "\e[0m") \ | |
LESS_TERMCAP_se=$(printf "\e[0m") \ | |
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ | |
LESS_TERMCAP_ue=$(printf "\e[0m") \ | |
LESS_TERMCAP_us=$(printf "\e[1;32m") \ | |
man "$@" | |
} | |
# Auto update of .bashrc and .bash_utils | |
function __bashrcUpdate() { | |
wget -q 'https://gist.githubusercontent.com/adamjedlicka/d053536063d01cd9ed48/raw/.bashrc' -O .bashrc.bak | |
[ -f .bashrc.bak ] && mv .bashrc.bak .bashrc | |
wget -q 'https://gist.githubusercontent.com/adamjedlicka/d053536063d01cd9ed48/raw/.bash_utils' -O .bash_utils.bak | |
[ -f .bash_utils.bak ] && mv .bash_utils.bak .bash_utils | |
if [ ! -f ~/.git-prompt.sh ]; then | |
wget -q 'https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh' | |
fi | |
} | |
if [ "$autoupdate" = true ]; then | |
(__bashrcUpdate &) | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment