-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotfiles.sh
More file actions
executable file
·129 lines (117 loc) · 3.19 KB
/
dotfiles.sh
File metadata and controls
executable file
·129 lines (117 loc) · 3.19 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
#!/bin/bash
THISDIR=$(dirname -- "$(readlink -f -- "$0";)";)
CONFIG_HOME="$HOME/.config"
function is_symlink_to {
if [[ -L "$2" ]]; then
if [[ "$(readlink -f "$2")" == "$(readlink -f "$1")" ]]; then
return 0
fi
fi
return 1
}
#######################################
# Link a config dir from dotfiles to the user's home directory
# Arguments:
# $1: The path of the config directory in the dotfiles directory
# $2: The path of the config directory in the user's home directory
#######################################
function link_config {
if is_symlink_to "$THISDIR/$1" "$CONFIG_HOME/$2"; then
echo -e "Already linked $1 config. Skipping..."
elif [[ -d "$CONFIG_HOME/$2" ]]; then
echo -e "$CONFIG_HOME/$2 already exists. Remove it before continuing. Skipping for now..."
return
else
ln -s "$THISDIR/$1" "$CONFIG_HOME/$2"
echo -e "Linked $1 config ($THISDIR/$1 -> $CONFIG_HOME/$2)"
fi
}
function kitty {
link_config terminals/kitty kitty
}
function fzf {
if ! grep -q "export FZF_DEFAULT_OPTS_FILE" "$HOME/.zshrc"; then
echo -e "Adding FZF_DEFAULT_OPTS_FILE to .zshrc..."
echo -e "\n# FZF Configuration\nexport FZF_DEFAULT_OPTS_FILE=\"$THISDIR/fzfrc\"\n" >> "$HOME/.zshrc"
else
echo -e "FZF_DEFAULT_OPTS_FILE already set in .zshrc. Skipping..."
fi
}
function ghostty {
link_config terminals/ghostty ghostty
}
function nvim {
link_config nvim nvim
}
function starship {
link_config starship.toml starship.toml
}
function tmux {
if [[ ! -d "$HOME/.tmux/plugins/tpm" ]]; then
echo -e "Installing Tmux Plugin Manager (tpm)..."
mkdir -p "$HOME/.tmux/plugins"
git clone --depth=1 "https://github.com/tmux-plugins/tpm" "$HOME/.tmux/plugins/tpm" &> /dev/null
fi
link_config tmux tmux
}
function zsh {
if [[ ! -d "$HOME/antigen" ]]; then
echo -e "Installing Antigen package manager..."
mkdir -p "$HOME/antigen"
curl -L git.io/antigen > "$HOME/antigen/antigen.zsh"
fi
}
function help {
echo -e "Usage: $0 [command] [options]"
echo -e ""
echo -e "This script runs any setup steps required for dotfiles in this repository"
echo -e ""
echo -e "Commands:"
echo -e " setup kitty Setup kitty terminal configuration"
echo -e " setup fzf Setup fzf by appending env var to .zshrc"
echo -e " setup ghostty Setup ghostty terminal configuration"
echo -e " setup nvim Setup Neovim configuration"
echo -e " setup starship Setup Starship prompt configuration"
echo -e " setup tmux Setup Tmux configuration with Tmux Plugin Manager (TPM)"
echo -e " setup zsh Setup Zsh configuration with Antigen package manager"
echo -e ""
echo -e "Options:"
echo -e " -h, --help Show this help message and exit"
}
case "$1" in
setup)
case "$2" in
kitty)
kitty
;;
fzf)
fzf
;;
ghostty)
ghostty
;;
nvim)
nvim
;;
starship)
starship
;;
tmux)
tmux
;;
zsh)
zsh
;;
*)
echo -e "Invalid setup command: $2"
exit 1
;;
esac
;;
-h|--help)
help
;;
*)
exit 1
;;
esac