dotfiles

$HOME is where the <3 is
git clone git://git.alexkarle.com/dotfiles.git
Log | Files | Refs | Submodules | README

commit e5a914b7dd093d67ea78a56cd1d6be7de42fbe36 (patch)
parent a17f7639bb36ad4a9f99ced85d5bb5e8cf05346d
Author: Alexander Karle <akarle@umass.edu>
Date:   Wed, 25 Apr 2018 20:07:54 -0400

Adding basic bash scripts for systems w/o zsh

I've decided that a minimal bash config that I
feel comfy in is both (1) good to have around and
(2) a good learning experience about the terminal!

I've done a good bit of "best practice" research
for putting together these files (specifically
bashrc vs bash_profile...).

For now, I'll continue to use oh-my-zsh because of its
awesome interactive features!

Diffstat:
Abash/aliases | 9+++++++++
Abash/bash_path | 9+++++++++
Abash/bash_profile | 13+++++++++++++
Abash/bash_prompt | 38++++++++++++++++++++++++++++++++++++++
Abash/bashrc | 8++++++++
5 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/bash/aliases b/bash/aliases @@ -0,0 +1,9 @@ +# ls aliases +alias l='ls -lAh' +alias ll='ls -lh' + +# Git aliases +alias ga='git add' +alias gp='git push' +alias gst='git status' +alias gl='git log --stat' diff --git a/bash/bash_path b/bash/bash_path @@ -0,0 +1,9 @@ +# Add Homebrew `/usr/local/bin` and User `~/bin` to the `$PATH` +PATH=/usr/local/bin:$PATH +PATH=$HOME/bin:$PATH + +# Add cargo to path +PATH="$HOME/.cargo/bin:$PATH" + +# Export it! +export PATH diff --git a/bash/bash_profile b/bash/bash_profile @@ -0,0 +1,13 @@ +# sourced by login shells (not interactive shells) +# Example: +# - ssh to Linux --> run bash_profile on login +# - open new tmux window --> run bashrc +# +# Exception: +# ** On OSX bash_profile is run by terminal emulators (new tabs, etc) ** +# +# Takeaway: +# ** Write preferences in bashrc, source it from bash_profile ** +if [ -r ~/.bashrc ]; then + source ~/.bashrc +fi diff --git a/bash/bash_prompt b/bash/bash_prompt @@ -0,0 +1,38 @@ +# Stripped down version of https://github.com/mathiasbynens/dotfiles/ +# Modified for my current uses / level of understanding + +# if you got xterm-256, export it! +if infocmp xterm-256color >/dev/null 2>&1; then + export TERM=xterm-256color +fi + +function parse_git_dirty() { + [[ $(git status 2> /dev/null | tail -n1) != *"working directory clean"* ]] && echo "*" +} + +function parse_git_branch() { + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/" +} + +# get colors from tput (else hardcode them) +if tput setaf 1 &> /dev/null; then tput sgr0 + if [[ $(tput colors) -ge 16 ]] 2>/dev/null; then + MAGENTA="\[$(tput setaf 5)\]" + ORANGE="\[$(tput setaf 11)\]" + GRAY="\[$(tput setaf 8)\]" + BLUE="\[$(tput setaf 12)\]" + BOLD="\[$(tput bold)\]" + RESET="\[$(tput sgr0)\]" + + export PS1="$BOLD$BLUE\w $RESET$GRAY\$(parse_git_branch)\n$BOLD$MAGENTA\$ $RESET" + export PS2="\[$ORANGE\]→ \[$RESET\]" + else + # TODO: write better case for too few colors... + export PS1="\w\n\$" + export PS2=">" + fi +else + # TODO: write better case for no tput... + export PS1="\w\n\$" + export PS2=">" +fi diff --git a/bash/bashrc b/bash/bashrc @@ -0,0 +1,8 @@ +# if interactive shell, disable XON/XOFF to allow forward search w CTRL-S +[[ $- == *i* ]] && stty -ixon + +# Load the shell dotfiles +for file in ~/.{bash_path,bash_prompt,bash_exports,aliases}; do + [ -r "$file" ] && source "$file" +done +unset file