-
Notifications
You must be signed in to change notification settings - Fork 9
/
bashrc_source
144 lines (122 loc) · 4.45 KB
/
bashrc_source
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
function update_dotfiles() {
echo "Updating ~/.bash_profile..."
if [ -f ~/.bashrc ]; then
echo "Loading ~/.bashrc"
source ~/.bashrc
elif [ -f ~/.bash_profile ]; then
echo "Loading ~/.bash_profile"
source ~/.bash_profile
fi
create_dot_vim
update_symlinks
reload_bash_profile
}
function create_dot_vim() {
if [ ! -d ~/.vim ]; then
echo "Creating ~/.vim"
mkdir ~/.vim
fi
if [ ! -d ~/.vim/colors ]; then
echo "Creating ~/.vim/colors"
mkdir ~/.vim/colors
fi
}
function update_symlinks(){
echo "Linking configuration files to ~/"
mkdir -p ~/.config/git
ln -nfs ~/.dotfiles/git/gitignore ~/.config/git/ignore
ln -nfs ~/.dotfiles/git/gitconfig ~/.gitconfig
ln -nfs ~/.dotfiles/git/githelpers ~/.githelpers
ln -nfs ~/.dotfiles/git/git_commit_template ~/.gitmessage
ln -nfs ~/.dotfiles/postgres/psqlrc ~/.psqlrc
ln -nfs ~/.dotfiles/vim/vimrc ~/.vimrc
ln -nfs ~/.dotfiles/vim/vim.plugins ~/.vim.plugins
ln -nfs ~/.dotfiles/vim/colorschemes/alex_ir_black.vim ~/.vim/colors/
# neovim
ln -nfs ~/.dotfiles/vim/nvimrc ~/.config/nvim/init.vim
mkdir -p ~/.config/nvim/colors/
ln -nfs ~/.dotfiles/vim/colorschemes/alex_ir_black.vim ~/.config/nvim/colors/
mkdir -p ~/.vim/after/
ln -nfs ~/.dotfiles/vim/snippets ~/.vim/after/
ln -nfs ~/.dotfiles/tmux/tmux.conf ~/.tmux.conf
ln -nfs ~/.dotfiles/tmux/tmux.versioning.conf ~/.tmux.versioning.conf
ln -nfs ~/.dotfiles/rc_files/pryrc ~/.pryrc
ln -nfs ~/.dotfiles/rc_files/irbrc ~/.irbrc
ln -nfs ~/.dotfiles/rc_files/amazing_print ~/.aprc
ln -nfs ~/.dotfiles/ag/ignore ~/.ignore
ln -nfs ~/.dotfiles/ag/ignore ~/.agignore
mkdir -p ~/.config/alacritty/
rm -f ~/.config/alacritty/alacritty.yml
ln -nfs ~/.dotfiles/alacritty/alacritty.yml ~/.alacritty.yml
# We don't use this directive anymore. We leave blank, which will default
# to $HOME/.config/git/ignore.
#
# git config --global core.excludesfile ~/.gitignore
}
function reload_bash_profile() {
# Loads .dotfiles
if [ -f ~/.bashrc ]; then
echo "Linking ~/.bashrc"
if ! grep -q "source ~/.dotfiles/bashrc_source" ~/.bashrc; then
echo 'source ~/.dotfiles/bashrc_source' >> ~/.bashrc
fi
source ~/.bashrc
elif [ -f ~/.bash_profile ]; then
echo "Linking ~/.bashrc"
if ! grep -q "source ~/.dotfiles/bashrc_source" ~/.bash_profile; then
echo 'source ~/.dotfiles/bashrc_source' >> ~/.bash_profile
fi
source ~/.bash_profile
else
echo "Error installing bashrc_source: Neither .bashrc nor .bash_profile found."
fi
}
export DOTFILES=~/.dotfiles
source $DOTFILES/bash/bash_profile
source $DOTFILES/bash/prompt_config
source $DOTFILES/bash/env
source $DOTFILES/bash/aliases
source $DOTFILES/bash/aliases_env_specific
source $DOTFILES/bash/autocomplete/autocomplete
source $DOTFILES/bash/dirmarks # This is neat
# FZF
export FZF_DEFAULT_COMMAND='rg --files --follow --ignore-vcs --hidden --sortr modified -g "!{.jest-cache*,*/node_modules/*,node_modules/*,.git/*}"'
export FZF_DEFAULT_OPTS='-i'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_ALT_C_COMMAND="$FZF_DEFAULT_COMMAND"
# Shows `tree` as preview for the current directory
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
# Loads FZF
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
# BASH HISTORY
export HISTCONTROL=ignoreboth
# If we're using tmux, use a specific history file for that session.
[[ -n "${TMUX+set}" ]] && export TMUX_SESSION=$(tmux display-message -p "#S")
if [[ $TMUX_SESSION ]]; then
export HISTFILE=$HOME/.bash_history_tmux_${TMUX_SESSION}
touch $HISTFILE
shopt -s histappend
# this makes history flush out to file after every command. Without it,
# history is only flushed when the session is closed.
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -n"
fi
export USER=`whoami`
export BASH_SILENCE_DEPRECATION_WARNING=1
export PATH=~/.dotfiles/bin:$PATH
export PATH=~/.dotfiles/bin/macos_only:$PATH
# MacOS only
if [[ "$OSTYPE" == "darwin"* ]]; then
export PATH="/opt/homebrew/bin:$PATH"
fi
# Node - if nodenv exists, eval it
nodenv --version &> /dev/null
if [[ $? -eq 0 ]]; then
eval "$(nodenv init -)"
fi
# disable XON/XOFF so I can use ctrl+s with `history`
[[ $- == *i* ]] && stty -ixon
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"
# We need some programs to be installed for this environment to work as expected
check_missing_binary 'bc'
check_missing_binary 'fzf'
check_missing_binary 'jq'