mirror of
https://github.com/joshuadavidthomas/dotfiles.git
synced 2025-12-23 05:36:53 +00:00
135 lines
4 KiB
Bash
Executable file
135 lines
4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -o errexit
|
|
set -o pipefail
|
|
set -o nounset
|
|
|
|
INSTALL_DIR=${HOME}/.dotfiles
|
|
OH_MY_ZSH_DIR=${HOME}/.oh-my-zsh
|
|
ZSH_CUSTOM=${OH_MY_ZSH_DIR}/custom
|
|
LOCAL_BIN_DIR=${HOME}/.local/bin
|
|
|
|
if [[ ! -d ${INSTALL_DIR} ]]; then
|
|
echo "Cloning dotfiles in to ${INSTALL_DIR}"
|
|
mkdir -p ${INSTALL_DIR}
|
|
git clone https://github.com/joshuadavidthomas/dotfiles.git ${INSTALL_DIR}
|
|
else
|
|
echo "Updating dotfiles"
|
|
cd ${INSTALL_DIR}
|
|
git pull
|
|
fi
|
|
|
|
[[ -d ${LOCAL_BIN_DIR} ]] || mkdir -p ${LOCAL_BIN_DIR}
|
|
|
|
set_kernal_and_machine_env_var () {
|
|
KERNAL=$(uname -s | tr "[:upper:]" "[:lower:]")
|
|
case "$(uname -m)" in
|
|
x86_64)
|
|
MACHINE=amd64
|
|
;;
|
|
i686 | i386)
|
|
MACHINE=386
|
|
;;
|
|
aarch64)
|
|
MACHINE=arm64
|
|
;;
|
|
*)
|
|
echo "Machine $(uname -m) not supported by the installer.\n" \
|
|
"Go to https://direnv for alternate installation methods."
|
|
exit 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
create_sym_links () {
|
|
ln -sf ${INSTALL_DIR}/.aliases ${HOME}/.aliases
|
|
ln -sf ${INSTALL_DIR}/.functions ${HOME}/.functions
|
|
ln -sf ${INSTALL_DIR}/.gitconfig ${HOME}/.gitconfig
|
|
ln -sf ${INSTALL_DIR}/.npmrc ${HOME}/.npmrc
|
|
ln -sf ${INSTALL_DIR}/.pythonrc ${HOME}/.pythonrc
|
|
ln -sf ${INSTALL_DIR}/.tmux.conf ${HOME}/.tmux.conf
|
|
ln -sf ${INSTALL_DIR}/.zprofile ${HOME}/.zprofile
|
|
ln -sf ${INSTALL_DIR}/.zshenv ${HOME}/.zshenv
|
|
ln -sf ${INSTALL_DIR}/.zshrc ${HOME}/.zshrc
|
|
|
|
for binary in ${INSTALL_DIR}/bin/*
|
|
do
|
|
ln -sf ${binary} ${LOCAL_BIN_DIR}
|
|
done
|
|
|
|
for config in ${INSTALL_DIR}/.config/*
|
|
do
|
|
ln -sf ${config} ${HOME}/.config
|
|
done
|
|
}
|
|
|
|
install_oh_my_zsh () {
|
|
if [[ ! -d $OH_MY_ZSH_DIR ]]; then
|
|
echo "Cloning oh-my-zsh in to ${OH_MY_ZSH_DIR}"
|
|
umask g-w,o-w
|
|
git clone -c core.eol=lf -c core.autocrlf=false \
|
|
-c fsck.zeroPaddedFilemode=ignore \
|
|
-c fetch.fsck.zeroPaddedFilemode=ignore \
|
|
-c receive.fsck.zeroPaddedFilemode=ignore \
|
|
--depth=1 --branch master https://github.com/ohmyzsh/ohmyzsh ${OH_MY_ZSH_DIR}
|
|
else
|
|
echo "Updating oh-my-zsh"
|
|
cd ${OH_MY_ZSH_DIR}
|
|
git pull
|
|
fi
|
|
}
|
|
|
|
install_tmux_plugin_manager () {
|
|
[[ -d "${HOME}/.tmux/plugins/tpm" ]] || git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
|
}
|
|
|
|
|
|
install_starship () {
|
|
sh -c "$(curl -fsSL https://starship.rs/install.sh)" -- --force --bin-dir ${LOCAL_BIN_DIR}
|
|
}
|
|
|
|
install_direnv () {
|
|
set_kernal_and_machine_env_var
|
|
download_url=$(
|
|
curl -fL https://api.github.com/repos/direnv/direnv/releases/latest \
|
|
| grep browser_download_url \
|
|
| cut -d '"' -f 4 \
|
|
| grep "direnv.$KERNAL.$MACHINE"
|
|
)
|
|
curl -o "${LOCAL_BIN_DIR}/direnv" -fL "$download_url"
|
|
chmod +x "${LOCAL_BIN_DIR}/direnv"
|
|
}
|
|
|
|
install_just () {
|
|
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --force --to ${LOCAL_BIN_DIR}
|
|
}
|
|
|
|
install_fzf () {
|
|
[[ -d ${HOME}/.fzf ]] || git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install --key-bindings --completion --update-rc --no-bash
|
|
}
|
|
|
|
install_gh_cli () {
|
|
set_kernal_and_machine_env_var
|
|
version=`curl "https://api.github.com/repos/cli/cli/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2-`
|
|
curl -sSL https://github.com/cli/cli/releases/download/v${version}/gh_${version}_${KERNAL}_${MACHINE}.tar.gz -o gh_${version}_${KERNAL}_${MACHINE}.tar.gz
|
|
tar xvf gh_${version}_${KERNAL}_${MACHINE}.tar.gz
|
|
mv gh_${version}_${KERNAL}_${MACHINE}/bin/gh ${LOCAL_BIN_DIR}/gh
|
|
sudo mv gh_${version}_${KERNAL}_${MACHINE}/share/man/man1/* /usr/share/man/man1/
|
|
chmod +x "${LOCAL_BIN_DIR}/gh"
|
|
}
|
|
|
|
copy_alacritty_config () {
|
|
if [[ -d /mnt/c ]]; then
|
|
cp -f ${INSTALL_DIR}/mnt/c/Users/jthomas/AppData/Roaming/Alacritty/alacritty.yml /mnt/c/Users/jthomas/AppData/Roaming/Alacritty/alacritty.yml
|
|
fi
|
|
}
|
|
|
|
create_sym_links
|
|
install_oh_my_zsh
|
|
install_tmux_plugin_manager
|
|
install_starship
|
|
install_direnv
|
|
install_just
|
|
install_fzf
|
|
install_gh_cli
|
|
copy_alacritty_config
|