-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathbashrc_source
More file actions
206 lines (173 loc) · 6.75 KB
/
bashrc_source
File metadata and controls
206 lines (173 loc) · 6.75 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# This file is sourced by .bashrc or .bash_profile. It works across MacOS and
# Linux.
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
mkdir -p ~/.dotfiles/.git/hooks
ln -nfs ~/.dotfiles/git/hooks/post-commit ~/.dotfiles/.git/hooks/post-commit
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
# Vim
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/
# VSCode
ln -nfs ~/.dotfiles/vscode/vimrc ~/.vscodevimrc
# 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
ln -nfs ~/.dotfiles/ai/aider.conf.yml ~/.aider.conf.yml
ln -nfs ~/.dotfiles/ai/claude.md ~/.claude/CLAUDE.md
ln -nfs ~/.dotfiles/ai/claude-settings.json ~/.claude/settings.json
# Claude AI config - merge public and private
# Remove old directory symlinks from previous dotfiles version (pre-f052657)
[ -L ~/.claude/commands ] && rm ~/.claude/commands
[ -L ~/.claude/skills ] && rm ~/.claude/skills
[ -L ~/.claude/agents ] && rm ~/.claude/agents
mkdir -p ~/.claude/commands ~/.claude/skills ~/.claude/agents
# Clean stale symlinks pointing to dotfiles (preserves private files)
find ~/.claude/commands -type l -lname "$HOME/.dotfiles/*" -delete 2>/dev/null || true
find ~/.claude/skills -type l -lname "$HOME/.dotfiles/*" -delete 2>/dev/null || true
find ~/.claude/agents -type l -lname "$HOME/.dotfiles/*" -delete 2>/dev/null || true
# Public commands/skills/agents from dotfiles
for f in ~/.dotfiles/ai/commands/*; do
[ -e "$f" ] && ln -nfs "$f" ~/.claude/commands/
done
mkdir -p ~/.codex/skills
find ~/.codex/skills -type l -lname "$HOME/.dotfiles/*" -delete 2>/dev/null || true
for f in ~/.dotfiles/ai/skills/*/; do
[ -d "$f" ] && ln -nfs "$f" ~/.claude/skills/
[ -d "$f" ] && ln -nfs "$f" ~/.codex/skills/
done
for f in ~/.dotfiles/ai/agents/*; do
[ -e "$f" ] && ln -nfs "$f" ~/.claude/agents/
done
# Claude hooks
mkdir -p ~/.claude/hooks
find ~/.claude/hooks -type l -lname "$HOME/.dotfiles/*" -delete 2>/dev/null || true
for f in ~/.dotfiles/ai/hooks/*; do
[ -e "$f" ] && ln -nfs "$f" ~/.claude/hooks/
done
# Codex CLI config
mkdir -p ~/.codex
ln -nfs ~/.dotfiles/ai/codex-agents.md ~/.codex/AGENTS.md
ln -nfs ~/.dotfiles/ai/codex-config.toml ~/.codex/config.toml
# Codex skills (spec requires ~/.agents/skills/, not ~/.codex/skills/)
mkdir -p ~/.agents/skills
find ~/.agents/skills -type l -lname "$HOME/.dotfiles/*" -delete 2>/dev/null || true
for f in ~/.dotfiles/ai/skills/*/; do
[ -d "$f" ] && ln -nfs "$f" ~/.agents/skills/
done
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'
# Modelines
# vim: set filetype=sh :