-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·124 lines (107 loc) · 4 KB
/
install.sh
File metadata and controls
executable file
·124 lines (107 loc) · 4 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
#!/usr/bin/env bash
# Install script for dotfiles
# Make required directories
if [ -z "${XDG_CONFIG_HOME}" ]; then
export XDG_CONFIG_HOME="${HOME}/.config"
export XDG_DATA_HOME="${XDG_CONFIG_HOME}/local/share"
export XDG_CACHE_HOME="${XDG_CONFIG_HOME}/cache"
export XDG_STATE_HOME="${XDG_CONFIG_HOME}/local/state"
fi
if [ ! -d "${XDG_CONFIG_HOME}" ]; then
mkdir -p "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" "${XDG_DATA_HOME}" "${XDG_STATE_HOME}"
fi
# Flags for dependencies install checks
r_flag=false
f_flag=false
# Install Dependencies
OS_NAME=""
RIPGREP_VERSION=14.1.0
RIPGREP_BIN_TYPE=""
case "${OSTYPE}" in
darwin*)
OS_NAME="osx"
if [[ $(uname -m) =~ "arm64" ]] || [[ $(uname -m) =~ "aarch64" ]]; then
RIPGREP_BIN_TYPE="aarch64-apple-darwin"
else
RIPGREP_BIN_TYPE="x86_64-apple-darwin"
fi
;;
linux-gnu)
OS_NAME="linux"
if [[ $(uname -m) =~ "arm64" ]] || [[ $(uname -m) =~ "aarch64" ]]; then
RIPGREP_BIN_TYPE="aarch64-unknown-linux-gnu"
elif [[ $(uname -m) =~ "x86_64" ]]; then
RIPGREP_BIN_TYPE="x86_64-unknown-linux-gnu"
elif [[ $(uname -m) =~ "i386" ]] || [[ $(uname -m) =~ "i686" ]]; then
RIPGREP_BIN_TYPE="i686-unknown-linux-gnu"
fi
;;
esac
if [ "${OS_NAME}" == "osx" ]; then
# Nerd fonts
brew tap homebrew/cask-fonts &&
brew install --cask font-hack-nerd-font &&
brew install --cask font-fira-code-nerd-font
elif [ "${OS_NAME}" == "linux" ]; then
if [ ! -d ${XDG_DATA_HOME}/fonts ]; then
mkdir ${XDG_DATA_HOME}/fonts
fi
mkdir /tmp/FiraCode &&
curl -o /tmp/FiraCode/FiraCode.zip -JL https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/FiraCode.zip &&
unzip /tmp/FiraCode/FiraCode.zip -d /tmp/FiraCode &&
mv /tmp/FiraCode/*.ttf ${XDG_DATA_HOME}/fonts/ &&
fc-cache -fv &&
rm -rf /tmp/FiraCode
fi
# ripgrep
curl -o /tmp/ripgrep-${RIPGREP_VERSION}-${RIPGREP_BIN_TYPE}.tar.gz -JL https://github.com/BurntSushi/ripgrep/releases/download/14.1.0/ripgrep-${RIPGREP_VERSION}-${RIPGREP_BIN_TYPE}.tar.gz &&
tar xvf /tmp/ripgrep-${RIPGREP_VERSION}-${RIPGREP_BIN_TYPE}.tar.gz -C /tmp/ &&
sudo mv /tmp/ripgrep-${RIPGREP_VERSION}-${RIPGREP_BIN_TYPE}/rg /usr/local/bin/rg &&
rm -rf /tmp/ripgrep-${RIPGREP_VERSION}-${RIPGREP_BIN_TYPE} /tmp/ripgrep-${RIPGREP_VERSION}-${RIPGREP_BIN_TYPE}.tar.gz
# Backup all current configs
if [ -f "${HOME}/.bashrc" ]; then
mv -f "${HOME}/.bashrc" "${HOME}/.bashrc.bak"
fi
if [ -f "${HOME}/.bash_profile" ]; then
mv -f "${HOME}/.bash_profile" "${HOME}/.bash_profile.bak"
fi
if [ -d "${XDG_CONFIG_HOME}/nvim" ]; then
mv -f "${XDG_CONFIG_HOME}/nvim" "${XDG_CONFIG_HOME}/nvim.bak"
fi
if [ -d "${XDG_CONFIG_HOME}/starship" ]; then
mv -f "${XDG_CONFIG_HOME}/starship" "${XDG_CONFIG_HOME}/starship.bak"
fi
if [ -d "${XDG_CONFIG_HOME}/tmux" ]; then
mv -f "${XDG_CONFIG_HOME}/tmux" "${XDG_CONFIG_HOME}/tmux.bak"
fi
DOTFILES_INSTALLED=1
DOWNLOAD_PATH="${XDG_CONFIG_HOME}/.dotfiles" &&
if [ -d "${DOWNLOAD_PATH}" ]; then
DOWNLOAD_PATH="${XDG_CONFIG_HOME}/.farazmd_dotfiles"
fi
# git clone
git clone -b master --recurse-submodules https://github.com/farazmd/dotfiles.git "${DOWNLOAD_PATH}" &&
# Install paths
DOTFILES_INSTALL_BASE_PATH="${XDG_CONFIG_HOME}" &&
NVIM_INSTALL_PATH="${DOTFILES_INSTALL_BASE_PATH}/nvim" &&
TMUX_INSTALL_PATH="${DOTFILES_INSTALL_BASE_PATH}/tmux" &&
STARSHIP_INSTALL_PATH="${DOTFILES_INSTALL_BASE_PATH}/starship" &&
# symlink all files to respective folders
# bash
ln -sf "${DOWNLOAD_PATH}/bash/.bash_profile" "${HOME}/.bash_profile" &&
ln -sf "${DOWNLOAD_PATH}/bash/.bashrc" "${HOME}/.bashrc" &&
# nvim
ln -sf "${DOWNLOAD_PATH}/nvim" "${NVIM_INSTALL_PATH}" &&
# startship
ln -sf "${DOWNLOAD_PATH}/starship" "${STARSHIP_INSTALL_PATH}" &&
# tmux
ln -sf "${DOWNLOAD_PATH}/tmux" "${TMUX_INSTALL_PATH}" &&
echo "Install successfull" &&
DOTFILES_INSTALLED=0
if [ ${DOTFILES_INSTALLED} -eq 0 ]; then
echo -e "\nDotfiles has been downloaded to ${DOWNLOAD_PATH}\n"
echo -e "All files have been symlinked to the below locations:"
echo -e "NVIM: ${NVIM_INSTALL_PATH}"
echo -e "TMUX: ${TMUX_INSTALL_PATH}"
echo -e "STARSHIP: ${STARSHIP_INSTALL_PATH}"
fi