Updated to work on both Linux and OSX; moved functions into a helper file; fixed my history
This commit is contained in:
parent
f8aed90c28
commit
479416b8c6
3 changed files with 64 additions and 52 deletions
55
bash/.bash_helpers.sh
Normal file
55
bash/.bash_helpers.sh
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
|
||||||
|
set_prompt() {
|
||||||
|
local BLUE="\[\e[0;34m\]"
|
||||||
|
local DARK_BLUE="\[\e[1;34m\]"
|
||||||
|
local RED="\[\e[0;31m\]"
|
||||||
|
local DARK_RED="\[\e[1;31m\]"
|
||||||
|
local GREEN="\[\e[0;32m\]"
|
||||||
|
local NO_COLOR="\[\e[0m\]"
|
||||||
|
|
||||||
|
case $TERM in
|
||||||
|
xterm*|screen)
|
||||||
|
TITLEBAR='\[\e]0;\u@\h \w\007\]';
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
TITLEBAR="";
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
FAILURE_COLOR="if [[ \$? = '0' ]]; then echo \"$GREEN\"; else echo \"$RED\"; fi"
|
||||||
|
|
||||||
|
PS1="${TITLEBAR}$BLUE[\t]\`$FAILURE_COLOR\` \u@\h> $NO_COLOR"
|
||||||
|
}
|
||||||
|
|
||||||
|
restart_network_manager() {
|
||||||
|
sudo service network-manager restart
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_ls() {
|
||||||
|
PLATFORM=$(uname)
|
||||||
|
# makes ls print pretty
|
||||||
|
case $PLATFORM in
|
||||||
|
Linux)
|
||||||
|
alias ls="ls --color=auto"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
alias ls="ls -G"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
configure_completions() {
|
||||||
|
# If the gcloud sdk is installed, set up completion for it
|
||||||
|
if [[ -e "$HOME/.install/google-cloud-sdk" ]]; then
|
||||||
|
source $HOME/.install/google-cloud-sdk/completion.bash.inc
|
||||||
|
source $HOME/.install/google-cloud-sdk/path.bash.inc
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If asdf is installed, set up completion for it
|
||||||
|
if [[ -e "$HOME/.asdf" ]]; then
|
||||||
|
source $HOME/.asdf/asdf.sh
|
||||||
|
source $HOME/.asdf/completions/asdf.bash
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,3 @@ then
|
||||||
. /etc/bash_completion
|
. /etc/bash_completion
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting
|
|
||||||
|
|
||||||
|
|
|
@ -1,70 +1,30 @@
|
||||||
|
|
||||||
# PS1="\[\e]0;\@ [\u@\h] [\w]\007\]\[\e[1;33m\]\@ \[\e[1;37m\][\[\e[1;35m\]\u\[\e[1;37m\]@\[\e[1;32m\]\h\[\e[1;37m\]] \[\e[1;37m\][\[\e[1;31m\]\w\[\e[1;37m\]] [\[\e[1;36m\]$(ls -l | grep "^-" | wc -l | tr -d " ") \[\e[1;34m\]files\[\e[1;37m\]] \n\[\e[1;33m\]\@ \[\e[1;37m\]$ \[\e[0m\]"
|
|
||||||
|
|
||||||
export SHELL=/bin/bash
|
export SHELL=/bin/bash
|
||||||
|
|
||||||
set_prompt() {
|
source ~/.bash_helpers.sh
|
||||||
local BLUE="\[\e[0;34m\]"
|
|
||||||
local DARK_BLUE="\[\e[1;34m\]"
|
|
||||||
local RED="\[\e[0;31m\]"
|
|
||||||
local DARK_RED="\[\e[1;31m\]"
|
|
||||||
local GREEN="\[\e[0;32m\]"
|
|
||||||
local NO_COLOR="\[\e[0m\]"
|
|
||||||
|
|
||||||
case $TERM in
|
|
||||||
xterm*|screen)
|
|
||||||
TITLEBAR='\[\e]0;\u@\h \w\007\]';
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
TITLEBAR="";
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
FAILURE_COLOR="if [[ \$? = '0' ]]; then echo \"$GREEN\"; else echo \"$RED\"; fi"
|
|
||||||
|
|
||||||
PS1="${TITLEBAR}$BLUE[\t]\`$FAILURE_COLOR\` \u@\h> $NO_COLOR"
|
|
||||||
}
|
|
||||||
|
|
||||||
restart_network_manager() {
|
|
||||||
sudo service network-manager restart
|
|
||||||
}
|
|
||||||
|
|
||||||
# sets the PS1 prompt
|
|
||||||
set_prompt
|
set_prompt
|
||||||
|
configure_ls
|
||||||
# makes ls print pretty
|
configure_completions
|
||||||
#alias ls="ls --color=auto"
|
|
||||||
# TODO: make this work on both platforms
|
|
||||||
alias ls="ls -G"
|
|
||||||
|
|
||||||
# default editor
|
# default editor
|
||||||
export EDITOR=vim
|
export EDITOR=vim
|
||||||
|
|
||||||
# set history
|
# set history
|
||||||
export HISTSIZE=1000
|
export HISTSIZE=10000 # very large history
|
||||||
export HISTFILESIZE=1000
|
export HISTFILESIZE=10000 # very large history
|
||||||
export HISTCONTROL=ignoredups,erasedups
|
export HISTCONTROL=ignoreboth:erasedups # ignore duplicate history entries
|
||||||
export PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
|
shopt -s histappend # append to the history when the shell exits (instead of overwriting)
|
||||||
shopt -s histappend
|
# save and reload history each time a command is run, to share history between shells
|
||||||
|
export PROMPT_COMMAND="history -a; history -c; history -r"
|
||||||
|
|
||||||
# disable messaging
|
# disable messaging
|
||||||
if `tty -s`; then
|
if `tty -s`; then
|
||||||
mesg n
|
mesg n
|
||||||
fi
|
fi
|
||||||
|
|
||||||
alias href="history -a; history -c; history -r"
|
|
||||||
|
|
||||||
export PATH=$PATH:~/.bin
|
export PATH=$PATH:~/.bin
|
||||||
export HISTCONTROL=ignorespace
|
|
||||||
export TERM=xterm-256color
|
export TERM=xterm-256color
|
||||||
|
|
||||||
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
|
|
||||||
|
|
||||||
source $HOME/.asdf/asdf.sh
|
|
||||||
source $HOME/.asdf/completions/asdf.bash
|
|
||||||
|
|
||||||
source $HOME/.install/google-cloud-sdk/completion.bash.inc
|
|
||||||
source $HOME/.install/google-cloud-sdk/path.bash.inc
|
|
||||||
|
|
||||||
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
|
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue