From 22ffcb09046a5a14b75b9b741318ce4029b43660 Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Fri, 13 Dec 2019 11:25:44 -0800 Subject: [PATCH] Significantly improve bash experience. --- README.md | 8 +++++++- dotfiles/bash/bash_profile | 13 +++++++++++++ dotfiles/bash/bashrc | 39 +++++++++++++++++++++++++++++++++++++++ dotfiles/bash/linuxrc | 0 dotfiles/bash/macrc | 12 ++++++++++++ dotfiles/bash_profile | 12 ------------ dotfiles/bashrc | 14 -------------- 7 files changed, 71 insertions(+), 27 deletions(-) create mode 100644 dotfiles/bash/bash_profile create mode 100644 dotfiles/bash/bashrc create mode 100644 dotfiles/bash/linuxrc create mode 100644 dotfiles/bash/macrc delete mode 100644 dotfiles/bash_profile delete mode 100644 dotfiles/bashrc diff --git a/README.md b/README.md index 99c0329..22ec64e 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,13 @@ The directory structure is as follows: ## Terminal After using zsh for a very long time I've gone back to bash. While it takes more work and I don't have as many conveniences I am starting to appreciate -the simplicity of making the terminal available everywhere work for me. +the simplicity of making the terminal available everywhere work for me. `dotfiles/bash` contains all of my work on my bash terminal setup. + +For OS X, symlink `scripts/dotfiles/bash/macrc` to `~/.macrc`. + +For Linux, symlink `scripts/dotfiles/bash/linuxrc` to `~/.linuxrc`. + +If you want better tab completion install `bash-completion` using your package manager. ## Vim diff --git a/dotfiles/bash/bash_profile b/dotfiles/bash/bash_profile new file mode 100644 index 0000000..f4844ec --- /dev/null +++ b/dotfiles/bash/bash_profile @@ -0,0 +1,13 @@ +[[ -r ~/.bashrc ]] && . ~/.bashrc +echo ".bashrc loaded" + +# Store private information (exports, keys, etc) in .bash_private. +[[ -r ~/.bash_private ]] && . ~/.bash_private +echo ".bash_private loaded" + +export CC=$(which clang) +export CXX=$(which clang++) +export OPENSSL_ROOT_DIR=$(which openssl) + +if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi + diff --git a/dotfiles/bash/bashrc b/dotfiles/bash/bashrc new file mode 100644 index 0000000..dbf7448 --- /dev/null +++ b/dotfiles/bash/bashrc @@ -0,0 +1,39 @@ +# Use the iterm2 material theme in the root directory of the essentials repository. For linux, +# you will need to source a material theme color scheme for your terminal. + +if [[ "$OSTYPE" == "darwin"* ]]; then + if [ -f ~/.macrc ]; then + source ~/.macrc + fi +fi + +parse_git_branch() { + git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' +} + +# If you ever needed weather... +weather() { + curl wttr.in +} + +# Test for the `bash-completion` package. Installing this adds better tab completion to bash. +[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh" + +# Ignore duplicates in history to make history less of a hassle to use. +export HISTCONTROL=ignoredups + +# Better color handling so scrolling doesn't get broken. +# Note for Cygwin you need ncurses for this to work. +reset=$(tput sgr0) +green=$(tput setaf 2) +blue=$(tput setaf 4) +white=$(tput setaf 7) + +bold=$(tput bold || tput md) + +export PROMPT_DIRTRIM=2 + +# Important note for PS1 modification - everything non-printable must be escaped with `\[` and `\]`. Otherwise readline +# fails to track the prompt right and things get messed up when you input long strings. +export PS1=\ +'\[$bold\]\[$white\]\u@\h\[$reset\]: \[$bold\]\[$blue\]\w\[$reset\] \[$green\]\[$(parse_git_branch)\]\[$reset\]\[$bold\]\[$white\]>\[$reset\] ' diff --git a/dotfiles/bash/linuxrc b/dotfiles/bash/linuxrc new file mode 100644 index 0000000..e69de29 diff --git a/dotfiles/bash/macrc b/dotfiles/bash/macrc new file mode 100644 index 0000000..39f80c3 --- /dev/null +++ b/dotfiles/bash/macrc @@ -0,0 +1,12 @@ +# Directory colors - note OS X does not use coreutils so dircolors doesn't work. +export CLICOLOR=YES + +# Custom directory colors +# Ex = Directory color - Bold blue, normal background (to match the $PS1 line) +# bx = Symlink color - Red, normal background +# Cx = Socket color - Bold green, normal background +# dx = Pipe color - Default +# Gx = Executable color - bold cyan +# The rest are default colors taken from `man ls` + +export LSCOLORS="ExbxCxdxGxegedabagacad" diff --git a/dotfiles/bash_profile b/dotfiles/bash_profile deleted file mode 100644 index 14046ef..0000000 --- a/dotfiles/bash_profile +++ /dev/null @@ -1,12 +0,0 @@ -[[ -r ~/.bashrc ]] && . ~/.bashrc -echo ".bashrc loaded" - -# Store private information (exports, keys, etc) in .bash_private. -[[ -r ~/.bash_private ]] && . ~/.bash_private -echo ".bash_private loaded" - -export CC=$(which clang) -export CXX=$(which clang++) - -if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi - diff --git a/dotfiles/bashrc b/dotfiles/bashrc deleted file mode 100644 index 782cb7d..0000000 --- a/dotfiles/bashrc +++ /dev/null @@ -1,14 +0,0 @@ -# Use the iterm2 material theme in the root directory of the essentials repository. For linux, -# you will need to source a material theme color scheme for your terminal. - -parse_git_branch() { - git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' -} - -# If you ever needed weather... -weather() { - curl wttr.in -} - -export PROMPT_DIRTRIM=2 -export PS1="\e[1;37m\u@\h\e[m: \e[1;34m\w\e[m \e[1;32m\[$(parse_git_branch)\]\e[m> "