-
Notifications
You must be signed in to change notification settings - Fork 2
/
install
executable file
·102 lines (80 loc) · 2.71 KB
/
install
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
#!/bin/bash
# set -x
set -e
{ #prevent exec until fully downloaded?
CWD=$(dirname -- "$(readlink -f -- "$0")")
DIR=~/.dotfiles
HOME=~/
function fetch_files() {
if [ "$CODESPACES" = true ]; then
echo "Running in codespaces..."
DIR="/workspaces/.codespaces/.persistedshare/dotfiles"
fi
if [ ! -d $DIR ]; then
git clone https://github.com/jsg2021/dotfiles.git $DIR
cd $DIR
# git submodule update --init --recursive
fi
}
function install_tools() {
if ! command -v fnm &>/dev/null; then
curl -fsSL https://fnm.vercel.app/install | bash
fi
if [ "$CODESPACES" = true ]; then
echo "Running in codespaces...skipping desktop apps"
else
sh $CWD/scripts/install-1password
sh $CWD/scripts/install-github
fi
install_my_tool bat fzf lsd entr ripgrep stow zoxide tmux neovim
if [ ! -d ~/.tmux/plugins/tpm ]; then
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
}
function install_homebrew() {
if ! command -v brew &>/dev/null; then
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
eval "$(/opt/homebrew/bin/brew shellenv)"
fi
}
function install_configs() {
stow -t $HOME -d $DIR -S configs
# stow -vvv -t $HOME -d $DIR -S configs
# set shell
if [[ "$SHELL" != $(which zsh) ]]; then
chsh -s $(which zsh)
if [[ "$OSTYPE" != "darwin"* ]]; then
echo "Reboot for SHELL change to take effect."
fi
fi
}
function install_linux() {
if [ "$CODESPACES" = true ]; then
echo "Running in codespaces...skip install_linux"
return
fi
install_my_tool xclip xsel
if [ ! -f /usr/local/bin/goto-windows ]; then
sudo ln -f -s ~/.dotfiles/scripts/goto-windows &&
mkdir -p ~/.local/share/applications &&
ln -f -s "$DIR/scripts/uefi-reboot.desktop" ~/.local/share/applications/uefi-reboot.desktop &&
ln -f -s "$DIR/scripts/goto-windows.desktop" ~/.local/share/applications/goto-windows.desktop
fi
}
function install_macos() {
if [ "$CODESPACES" = true ]; then
echo "Running in codespaces...skip install_macos"
return
fi
install_homebrew
}
fetch_files
source $DIR/scripts/install-function
if [[ "$OSTYPE" == "darwin"* ]]; then
install_macos
else
install_linux
fi
install_tools
install_configs
}