This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/shell/bash/bashrc

121 lines
3.2 KiB
Bash
Raw Normal View History

2017-02-07 16:16:45 -06:00
#!/usr/bin/env bash
2018-11-08 09:34:17 -06:00
# these are all paths used across many of the dotfiles and should be assumed to
# be loaded and properly set by every script - this means you are responsible
# for making sure they're loaded!
2017-02-07 16:16:45 -06:00
export XDG_CONFIG_HOME="$HOME/.config"
export DOTFILES_PATH="$XDG_CONFIG_HOME/dotfiles"
NICE_HOME="$HOME"
2018-11-08 09:34:17 -06:00
# TODO: better logic for auto-detecting alternative home directories?
# 1. check dirname(basename $HOME)) matches username
# 2. check /home/$username
[[ $(basename "${HOME}") = "usr" ]] && NICE_HOME="$(realpath "$HOME/..")"
[[ $(basename "${HOME}") = ".home" ]] && NICE_HOME="$(realpath "$HOME/..")"
2018-11-08 09:34:17 -06:00
# TODO: nice home explicitly definable on a per-device (env) basis
export NICE_HOME
2018-11-08 07:32:36 -06:00
export NOTES_DIR="$NICE_HOME/doc/notes"
2017-02-07 16:16:45 -06:00
2017-04-14 11:52:18 -05:00
# set our PATH
2018-11-08 07:32:36 -06:00
source "$DOTFILES_PATH/shell/bash/paths"
2017-02-20 18:31:28 -06:00
# stop parsing on a non-interactive shell
[ -z "$PS1" ] && return
2017-02-07 16:16:45 -06:00
# load our key binds
2018-11-08 09:34:17 -06:00
case $- in
*i*) bind -f "$DOTFILES_PATH/shell/inputrc";;
*) ;;
esac
2017-11-13 15:55:11 -06:00
# import our aliases
source "$DOTFILES_PATH/shell/bash/aliases"
# import our autocompletions
source "$DOTFILES_PATH/shell/bash/autocompletions"
# load our vconsole colors
if [ "${TERM%%-*}" = 'linux' ] && [[ $- == *i* ]]; then
BASE16_SHELL="$DOTFILES_PATH/scripts/colors/vconsole"
[[ -s "$BASE16_SHELL" ]] && source "$BASE16_SHELL"
fi
# load our terminal colors
BASE16_SHELL="$DOTFILES_PATH/scripts/colors/shell"
[[ -s "$BASE16_SHELL" ]] && source "$BASE16_SHELL"
# disable ctrl-s terminal freeze
[[ $- == *i* ]] && stty -ixon
# allow ** recursive wildcard globbing
shopt -s globstar
# import our prompt
2018-11-08 07:32:36 -06:00
source "$DOTFILES_PATH/shell/bash/prompt"
2017-02-07 16:16:45 -06:00
# prevents binds or commands pulling from history from insta-sending, and
# instead places them in the readline for editing
shopt -s histverify
# always _append_ to bash history
shopt -s histappend
2017-02-07 16:16:45 -06:00
# prevents some Java GUI apps from not working or rendering properly due to
2018-11-08 09:34:17 -06:00
# using wacky window managers
2017-02-07 16:16:45 -06:00
export _JAVA_AWT_WM_NONREPARENTING=1
2018-11-08 09:34:17 -06:00
LS_COLORS='ow=01;36;40'
export LS_COLORS
# less tab size of 2 spaces
LESS="-x2"
export LESS
# set our EDITOR to neovim if we've got it
export EDITOR="vim"
if command -v nvim >/dev/null 2>&1; then
alias vim="nvim"
alias ovim="\\vim"
export EDITOR="nvim"
fi
2019-05-08 13:31:23 -05:00
export TERMINAL="urxvtc"
2018-11-08 09:34:17 -06:00
export BROWSER="firefox-developer-edition"
# "unlimited" history
export HISTFILESIZE="10000000"
export HISTSIZE="10000000"
# ignore duplicates and commands starting with space (" ")
export HISTCONTROL=ignoreboth
# ignore certain commands
HISTIGNORE='ls:ll:la'
# ensure command history is comprised of single lines
shopt -s cmdhist
2018-11-14 08:34:53 -06:00
2017-02-07 16:16:45 -06:00
# load a per-device config last so anything can be overridden
if [ -a "$HOME/.env_bashrc" ]; then
2018-11-16 16:37:21 -06:00
source "$HOME/.env_bashrc"
2017-02-07 16:16:45 -06:00
fi
# we assume the user uses "$HOME" to just store their mess of dotfiles and other
# nonsense that clutters it up and that they have a preferred starting
# directory where they keep the stuff they actually care about
# we only do this if the user is opening a shell at $HOME
if [ "$PWD" = "$HOME" ]; then
2018-11-16 16:37:21 -06:00
cd "$NICE_HOME" || cd || return
2017-02-07 16:16:45 -06:00
fi
2017-02-20 18:31:28 -06:00
2019-03-13 07:36:53 -05:00
# TODO: check if fd command exists
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
2019-06-09 09:49:32 -05:00
export ERL_AFLAGS="-kernel shell_history enabled"
2018-11-03 14:06:15 -05:00
_make_paths
2017-02-20 18:31:28 -06:00
[ -f ~/.fzf.bash ] && source ~/.fzf.bash