Skip to content

Instantly share code, notes, and snippets.

@KalenAnson
Last active August 7, 2017 19:07
Show Gist options
  • Save KalenAnson/881a35dfb21c19510e383761b667b5a4 to your computer and use it in GitHub Desktop.
Save KalenAnson/881a35dfb21c19510e383761b667b5a4 to your computer and use it in GitHub Desktop.
OSX Dot Files
# Change to dev directory
alias dev="cd ~/Development"
# ø Bash Profile
# Add `~/bin` to the `$PATH`
export PATH="$HOME/bin:$PATH";
# Load additional dotfiles
for file in ~/.{bash_prompt,exports,aliases}; do
[ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
unset file;
# Case-insensitive globbing (used in pathname expansion)
shopt -s nocaseglob;
# Append to the Bash history file, rather than overwriting it
shopt -s histappend;
# Autocorrect typos in path names when using `cd`
shopt -s cdspell;
# Enable some Bash 4 features when possible:
# * `autocd`, e.g. `**/qux` will enter `./foo/bar/baz/qux`
# * Recursive globbing, e.g. `echo **/*.txt`
for option in autocd globstar; do
shopt -s "$option" 2> /dev/null;
done;
# Add tab completion for many Bash commands
if which brew > /dev/null && [ -f "$(brew --prefix)/etc/bash_completion" ]; then
source "$(brew --prefix)/etc/bash_completion";
elif [ -f /etc/bash_completion ]; then
source /etc/bash_completion;
fi;
# Add tab completion for SSH hostnames based on ~/.ssh/config, ignoring wildcards
[ -e "$HOME/.ssh/config" ] && complete -o "default" -o "nospace" -W "$(grep "^Host" ~/.ssh/config | grep -v "[?*]" | cut -d " " -f2- | tr ' ' '\n')" scp sftp ssh;
# Add npm globally installed packages to path
export PATH="$HOME/.npm-packages/bin:/usr/local/sbin:$PATH"
# Adding n, npm and node to path
export N_PREFIX="$HOME/n"; [[ :$PATH: == *":$N_PREFIX/bin:"* ]] || PATH+=":$N_PREFIX/bin"
#!/bin/bash
# Custom Prompt
# ø
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM='gnome-256color';
elif infocmp xterm-256color >/dev/null 2>&1; then
export TERM='xterm-256color';
fi;
prompt_git() {
local s='';
local branchName='';
# Check if the current directory is in a Git repository.
if [ $(git rev-parse --is-inside-work-tree &>/dev/null; echo "${?}") == '0' ]; then
# check if the current directory is in .git before running git checks
if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == 'false' ]; then
# Ensure the index is up to date.
git update-index --really-refresh -q &>/dev/null;
# Check for uncommitted changes in the index.
if ! $(git diff --quiet --ignore-submodules --cached); then
s+='+';
fi;
# Check for unstaged changes.
if ! $(git diff-files --quiet --ignore-submodules --); then
s+='!';
fi;
# Check for untracked files.
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
s+='?';
fi;
# Check for stashed files.
if $(git rev-parse --verify refs/stash &>/dev/null); then
s+='$';
fi;
fi;
# Get the short symbolic ref.
# If HEAD isn’t a symbolic ref, get the short SHA for the latest commit
# Otherwise, just give up.
branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
git rev-parse --short HEAD 2> /dev/null || \
echo '(unknown)')";
[ -n "${s}" ] && s=" [${s}]";
echo -e "${1}${branchName}${blue}${s}";
else
return;
fi;
}
if tput setaf 1 &> /dev/null; then
tput sgr0; # reset colors
bold=$(tput bold);
reset=$(tput sgr0);
# Custom overbyte
lgray=$(tput setaf 243);
dgray=$(tput setaf 237);
black=$(tput setaf 0);
blue=$(tput setaf 33);
cyan=$(tput setaf 7);
green=$(tput setaf 64);
orange=$(tput setaf 202);
purple=$(tput setaf 93);
red=$(tput setaf 160);
violet=$(tput setaf 55);
white=$(tput setaf 254);
yellow=$(tput setaf 220);
else
bold='';
lgray="\e[1;37m";
dgray="\e[1;37m";
reset="\e[0m";
black="\e[1;30m";
blue="\e[1;34m";
cyan="\e[1;36m";
green="\e[1;32m";
orange="\e[1;33m";
purple="\e[1;35m";
red="\e[1;31m";
violet="\e[1;35m";
white="\e[1;37m";
yellow="\e[1;33m";
fi;
# Highlight the user name when logged in as root.
if [[ "${USER}" == "root" ]]; then
userStyle="${red}";
else
userStyle="${blue}";
fi;
# Highlight the hostname when connected via SSH.
if [[ "${SSH_TTY}" ]]; then
hostStyle="${bold}${red}";
else
hostStyle="${yellow}";
fi;
# Set the terminal title to the current working directory.
PS1="\[\033]0;\w\007\]";
PS1+="\[${bold}\]\n"; # newline
PS1+="\[${userStyle}\]ø "; # username
PS1+="\[${lgray}\]\w"; # working directory
# Don't show git details as root
if [[ "${USER}" != "root" ]]; then
PS1+="\$(prompt_git \"${dgray} on ${yellow}\")"; # Git repository details
fi
PS1+="\n";
PS1+="\[${yellow}\]\$ \[${reset}\]"; # `$` (and reset color)
export PS1;
PS2="\[${yellow}\]→ \[${reset}\]";
export PS2;
################################################################################ [58/9337]
# _
# | |_ _ __ ___ _ ___ __
# | __| '_ ` _ \| | | \ \/ /
# | |_| | | | | | |_| |> <
# \__|_| |_| |_|\__,_/_/\_\
#
################################################################################
# ø
################################################################################
################################################################################
# Unbind Keys
################################################################################
unbind [ # copy mode bound to escape key
unbind '"' # unbind horizontal split
unbind % # unbind vertical split
################################################################################
# CTRL-A instead of CTRL-B
################################################################################
set -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix
################################################################################
# Other Bindings
################################################################################
# Make escape the key to start copy mode (also CTRL-[)
bind Escape copy-mode
# New split in current pane (horizontal / vertical)
bind-key - split-window -v # split pane horizontally
bind-key \ split-window -h # split pane vertically
# Bind vim moment keys for switching between panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
################################################################################
# Global options
################################################################################
set -g default-shell $SHELL # Set Shell
set -g history-limit 10000 # History
set -g bell-action any # Listen for activity on all windows
set -g display-panes-time 2000
set -g visual-activity on
set -g visual-bell on
set -g default-terminal "screen-256color" # "xterm-256color"
set -g set-titles-string "tmux:#I #W" # wm window title string
#set -g utf8 on # UTF
#setw -g utf8 on # UTF
set -g set-titles on # enable wm window titles
setw -g xterm-keys on # Vim
setw -g mode-keys vi # Vi
# Reload ~/.tmux.conf using PREFIX r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
################################################################################
# Status Bar
################################################################################
set -g status on
#set -g status-utf8 on
set -g status-justify centre
set -g status-interval 5
set -g status-bg colour045
set -g status-fg colour016
set -g status-attr bright
set -g status-interval 5
set -g status-justify centre
set -g status-left-length 90
set -g status-right-length 100
set -g status-right ""
set -g status-left ""
################################################################################
# Theme
################################################################################
setw -g window-status-format " #F#I:#W#F "
setw -g window-status-current-format " #F#I:#W#F "
setw -g window-status-current-bg colour027
setw -g window-status-current-fg colour015
setw -g window-status-current-attr bright
setw -g window-status-bg colour039
setw -g window-status-fg colour240
setw -g window-status-attr bright
set-window-option -g window-status-bell-attr none
set-window-option -g window-status-bell-bg colour9
# Messages
set -g message-fg colour016
set -g message-bg colour046
set -g message-attr bright
# Panes
set -g pane-active-border-bg default
set -g pane-active-border-fg red
set -g pane-border-bg default
set -g pane-border-fg default
# Left side status bar
set -g status-left-length 90
# Hostname
set -g status-left "#{?client_prefix,#[reverse],}#[bg=colour027,fg=colour015] #h "
# Interface addresses
set -ga status-left "#[bg=colour033,fg=colour016]#(ifconfig en0 | grep 'inet ' | awk '{print \" #[fg=colour017]en0:#[fg=colour015]\" $2 }') "
set -ga status-left "#[bg=colour039,fg=colour016]#(ifconfig en3 | grep 'inet ' | awk '{print \" #[fg=colour017]en3:#[fg=colour015]\" $2 }') "
## CMUS (Optional)
#set -ga status-left "#[bg=colour039,fg=colour015] #(if [[ -a /Users/overbyte/cmus-tmux-statusbar.sh ]]; then /Users/overbyte/cmus-tmux-statusbar.sh | cut -c-70; else echo 'cmus: - stopped -'; fi) "
# System Load (Optional)
# Requires https://github.com/thewtex/tmux-mem-cpu-load
#set -ga status-left " #[bg=colour039,fg=colour016] #(tmux-mem-cpu-load --interval 2) "
# Right side status bar
set -g status-right-length 90
# Tmux session
set -ga status-right "#[bg=colour039,fg=colour015] #S #I:#P "
# Date
set -ga status-right "#[bg=colour033,fg=colour015] %d %b %Y "
# Time
set -ga status-right "#[bg=colour027,fg=colour015] %H:%M "
################################################################################
# Sessions
################################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment