2016-10-14 21:59:34 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2012-06-18 01:10:31 +02:00
|
|
|
########################################################################
|
|
|
|
# bash_profile, basically from the whole internet
|
|
|
|
# and a lot from @necolas, @mathiasbynens & @rtomayko
|
2013-01-27 11:24:46 +01:00
|
|
|
#
|
2012-06-18 01:10:31 +02:00
|
|
|
# https://github.com/mathiasbynens/dotfiles
|
|
|
|
# https://github.com/necolas/dotfiles
|
|
|
|
# https://github.com/rtomayko/dotfiles
|
|
|
|
########################################################################
|
|
|
|
|
2017-09-10 14:40:28 +02:00
|
|
|
# shellcheck source=/dev/null
|
2012-06-18 01:10:31 +02:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
2012-06-25 18:51:11 +02:00
|
|
|
# Load ~/.private, ~/.bash_prompt
|
2012-06-18 01:10:31 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2017-09-10 14:40:28 +02:00
|
|
|
for FILE in ~/.{bash_exports,bash_paths,bash_prompt,bash_aliases,private,inputrc}; do
|
|
|
|
[ -r "$FILE" ] && [ -f "$FILE" ] && source "$FILE"
|
2014-09-01 10:59:24 +02:00
|
|
|
done;
|
2017-09-10 14:40:28 +02:00
|
|
|
unset FILE;
|
2012-06-18 01:10:31 +02:00
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# SHELL OPTIONS
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2012-07-15 05:26:24 +02:00
|
|
|
# Append to the Bash history file, rather than overwriting it
|
|
|
|
shopt -s histappend
|
|
|
|
|
2017-03-24 03:12:46 +01:00
|
|
|
# Save multi-line commands as one command
|
|
|
|
shopt -s cmdhist
|
|
|
|
|
|
|
|
# Avoid duplicate entries
|
|
|
|
HISTCONTROL="erasedups:ignoreboth"
|
|
|
|
|
|
|
|
# Don't record some commands
|
|
|
|
export HISTIGNORE="&:[ ]*:exit:ls:bg:fg:history:clear"
|
|
|
|
|
2012-06-18 01:10:31 +02:00
|
|
|
# fuck that you have new mail shit
|
|
|
|
unset MAILCHECK
|
|
|
|
|
2014-05-23 16:11:05 +02:00
|
|
|
# Case-insensitive globbing (used in pathname expansion)
|
|
|
|
shopt -s nocaseglob
|
|
|
|
|
2017-03-24 03:12:46 +01:00
|
|
|
# Turn on recursive globbing (enables ** to recurse all directories)
|
|
|
|
shopt -s globstar 2> /dev/null
|
2014-05-23 16:11:05 +02:00
|
|
|
|
2017-03-24 03:12:46 +01:00
|
|
|
# Prepend cd to directory names automatically
|
|
|
|
shopt -s autocd 2> /dev/null
|
|
|
|
|
|
|
|
# Correct spelling errors during tab-completion
|
|
|
|
shopt -s dirspell 2> /dev/null
|
|
|
|
|
|
|
|
# Correct spelling errors in arguments supplied to cd
|
|
|
|
shopt -s cdspell 2> /dev/null
|
|
|
|
|
|
|
|
# Update window size after every command
|
|
|
|
shopt -s checkwinsize
|
|
|
|
|
|
|
|
# Automatically trim long paths in the prompt (requires Bash 4.x)
|
|
|
|
PROMPT_DIRTRIM=4
|
2014-09-01 10:59:24 +02:00
|
|
|
|
2014-05-23 16:11:05 +02:00
|
|
|
# Add tab completion for many Bash commands
|
2018-11-25 17:38:26 +01:00
|
|
|
if type brew 2&>/dev/null; then
|
|
|
|
for completion_file in $(brew --prefix)/etc/bash_completion.d/*; do
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
source "$completion_file"
|
|
|
|
done
|
|
|
|
fi
|
2014-05-23 16:11:05 +02:00
|
|
|
|
2017-03-24 03:12:46 +01:00
|
|
|
# Perform file completion in a case insensitive fashion
|
|
|
|
bind "set completion-ignore-case on"
|
|
|
|
|
|
|
|
# Treat hyphens and underscores as equivalent
|
|
|
|
bind "set completion-map-case on"
|
|
|
|
|
|
|
|
# Display matches for ambiguous patterns at first tab press
|
|
|
|
bind "set show-all-if-ambiguous on"
|
|
|
|
|
|
|
|
# Immediately add a trailing slash when autocompleting symlinks to directories
|
|
|
|
bind "set mark-symlinked-directories on"
|
|
|
|
|
2014-11-03 17:40:13 +01:00
|
|
|
# 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;
|
2012-06-18 21:46:35 +02:00
|
|
|
|
2014-11-03 17:40:13 +01:00
|
|
|
# Add `killall` tab completion for common apps
|
|
|
|
complete -o "nospace" -W "Contacts Calendar Dock Finder Mail Safari iTunes SystemUIServer Terminal" killall;
|
2012-06-18 01:10:31 +02:00
|
|
|
|
2014-11-03 17:40:13 +01:00
|
|
|
# aws-cli tab completion
|
|
|
|
complete -C aws_completer aws
|
2015-01-13 16:27:03 +01:00
|
|
|
|
|
|
|
|
2015-03-28 02:42:45 +01:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# rvm
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2015-01-13 16:27:03 +01:00
|
|
|
# Load RVM into a shell session *as a function*
|
2017-09-10 14:46:58 +02:00
|
|
|
# shellcheck source=/dev/null
|
2018-10-22 23:16:39 +02:00
|
|
|
# [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
|
2017-06-12 01:01:56 +02:00
|
|
|
|
|
|
|
|
2018-07-10 13:01:31 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# nvm
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
2018-09-20 22:50:23 +02:00
|
|
|
if [ -s "$HOME/.nvm" ]; then
|
|
|
|
export NVM_DIR="$HOME/.nvm"
|
|
|
|
. "/usr/local/opt/nvm/nvm.sh"
|
|
|
|
fi
|
2018-07-10 13:01:31 +02:00
|
|
|
|
2017-06-12 01:01:56 +02:00
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
# ssh hack for SSH_AUTH_SOCK
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
|
|
|
|
if [ -S "$SSH_AUTH_SOCK" ]; then
|
|
|
|
unset SSH_AUTH_SOCK
|
|
|
|
fi
|