-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·196 lines (146 loc) · 5.1 KB
/
build
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
#!/bin/bash
# This setup script takes all the rc files stored in this .dotfiles and symlinks them to their correct location in the system. Further to this it appends the scripts folder which is aliased to ~/.local/bin/scripts to path. By doing this we are able to make use of all the scripts developed by rwxrob and can use scripts such as newx to create our own scripts which are automatically added to this location.
set -e
DOT=$(pwd)
x__pathappend() {
for ARG in "$@"; do
test -d "${ARG}" || continue
case ":${PATH}:" in
*:${ARG}:*) continue ;;
esac
export PATH="${PATH:+"${PATH}:"}${ARG}"
echo "$PATH"
done
}
x_nap() {
go install github.com/maaslalani/nap@main
ln -sr "$DOT/.nap" "$HOME"
}
x_scripts() {
echo "Setting Scripts variable and adding scripts to path"
export SCRIPTS=~/.local/bin/scripts
test ! -d "$HOME/.local/bin" && mkdir -p "$HOME/.local/bin"
ln -sf "$PWD/scripts" "$HOME/.local/bin/"
echo "adding scripts to path"
if test -e ~/.bashrc-personal; then
x__pathappend \
"$SCRIPTS/"
fi
}
x_addDirs() {
mkdir -p $HOME/.sshrc.d
#mkdir -p $HOME/.local/share/ansible
mkdir -p $HOME/.bash_completion.d
mkdir -p $HOME/.config/bspwm
mkdir -p $HOME/.config/sxhkd
mkdir -p $HOME/.config/polybar
#mkdir -p ~/.gnupg
}
x_bash() {
ln -sf "$DOT/bash/.bashrc" "$HOME"
ln -sf "$DOT/bash/.bash_prompt" "$HOME/.bash_prompt"
ln -sf "$DOT/bash/prompt_configs" "$HOME/prompt_configs"
ln -sf "$DOT/bash/aliases" "$HOME/.aliases"
## starship
ln -sf "$DOT/bash/starship" "$HOME/.config/starship"
}
x_syms() {
# Create symlinks.
echo "Creating Symlinks"
# ----------------------------------- bash -----------------------------------
ln -sf "$DOT/bash/.bashrc" "$HOME"
# --------------------------------- dircolors --------------------------------
ln -sf "$DOT/.dircolors" "$HOME/.dircolors"
# ----------------------------------- tmux -----------------------------------
ln -sf "$DOT/tmux/.tmux.conf" "$HOME/.tmux.conf"
ln -sf "$DOT/tmux/tmux.reset.conf" "$HOME/.config/tmux/"
# ------------------------------------ vim -----------------------------------
ln -sf "$DOT/vim/.vimrc" "$HOME/.vimrc"
ln -sf "$DOT/vim/.vimrc" "$HOME/.sshrc.d"
#x_wm_syms
#x_comp_syms
}
# ---------------------------- Additional symlinks ---------------------------
x_sysutils() {
ln -sf "$DOT/x/.xinitrc" "$HOME/.xinitrc"
ln -sf "$DOT/x/.Xresources" "$HOME/.Xresources"
}
# ---------------------------------- sxhkd ----------------------------------
x_sxhkd() {
_have sxhkd && ln -sf "$DOT/.config/sxhkd/" "$HOME/.config/"
}
x_wm_syms() {
#bspwm
_have bspwm && ln -sf "$DOT/.config/bspwm" "$HOME/.config"
_have polybar && ln -sf "$DOT/.config/polybar" "$HOME/.config"
x_sxhkd
#xmonad
}
x_fz_tools() {
ln -sf "$DOT/bash/fztricks-bash" "$HOME/fztricks-bash"
ln -sf "$DOT/bash/.fztricks.bash" "$HOME/.fztricks.bash"
}
x_comp_syms() {
# ---------------------------- ansible_completion ----------------------------
# -------------------------------- Completions -------------------------------
mkdir ~/.bash_completion.d
ln -sf "$DOT/completions/z.sh" "$HOME/.bash_completion.d/z.sh"
ln -sf "$DOT/completions/fz.sh" "$HOME/.bash_completion.d/fz.sh"
ln -sf "$DOT/completions/gh/.gh_comp" "$HOME/"
ln -sf "$DOT/completions/task.bash" "$HOME/"
ln -sf "$DOT/completions/ansible-completion/" "$HOME/.local/share/ansible/ansible-completion"
}
x_usage() {
local cmds="${COMMANDS[*]}"
printf "usage: %s (%s)\n" "${0##*/}" "${cmds// /|}"
}
x_gitconfig() {
#info "Configuring Git"
# The .gitconfig will be overwritten; reconfigure it.
echo "Configuring global .gitignore"
git config --global core.excludesfile ~/.gitignore_global
git config --global user.name "qwertimer"
git config --global user.email [email protected]
git config --global core.editor vim
git config --global merge.tool meld
git config --global diff.external meld
}
x_gitconfigw() {
info "Configuring Git for work"
# The .gitconfig will be overwritten; reconfigure it.
echo "Configuring global .gitignore"
git config --global core.excludesfile ~/.gitignore_global
git config --global user.name "tim-polydatum"
git config --global user.email [email protected]
git config --global core.editor vim
git config --global merge.tool meld
git config --global diff.external meld
}
# --------------------------------- Utilities --------------------------------
_have() { type "$1" &>/dev/null; }
# --------------------- completion and delegation --------------------
while IFS= read -r line; do
[[ $line =~ ^declare\ -f\ x_ ]] || continue
COMMANDS+=( "${line##declare -f x_}" )
done < <(declare -F)
if [[ -n $COMP_LINE ]]; then
line=${COMP_LINE#* }
for c in "${COMMANDS[@]}"; do
[[ ${c:0:${#line}} == "${line,,}" ]] && echo "$c"
done
exit
fi
for c in "${COMMANDS[@]}"; do
if [[ $c == "$EXE" ]]; then
"x_$EXE" "$@"
exit $?
fi
done
declare cmd="$1"; shift
for c in "${COMMANDS[@]}"; do
if [[ $c == "$cmd" ]]; then
"x_$cmd" "$@"
exit $?
fi
done
x_usage "$@"