2020-04-21 12:39:18 -04:00
|
|
|
#!/bin/bash
|
2021-10-06 09:40:58 -04:00
|
|
|
|
2024-01-22 13:30:45 -05:00
|
|
|
echo "Initializing dotfiles..."
|
|
|
|
|
2023-08-26 00:31:52 -04:00
|
|
|
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
|
|
|
|
FAKE_HOME="$SCRIPT_DIR/fake_home"
|
2024-01-20 18:23:14 -05:00
|
|
|
export f="$FAKE_HOME"
|
2021-10-06 12:47:19 -04:00
|
|
|
|
2024-08-29 14:26:28 -04:00
|
|
|
function require {
|
|
|
|
local success=true
|
|
|
|
for comm in "$@"; do
|
|
|
|
if ! command -v "$comm" &> /dev/null; then
|
|
|
|
echo "$comm must be installed!"
|
|
|
|
success=false
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if ! $success; then
|
|
|
|
echo "Missing copy.sh dependencies! Exiting!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-10-04 10:01:28 -04:00
|
|
|
if ! command -v gron &> /dev/null; then
|
|
|
|
wget 'https://github.com/tomnomnom/gron/releases/download/v0.7.1/gron-linux-amd64-0.7.1.tgz' -O gron.tgz
|
|
|
|
tar -xvf gron.tgz
|
|
|
|
mv gron "$HOME/.bin"
|
|
|
|
rm gron.tgz
|
|
|
|
fi
|
|
|
|
|
2024-10-04 11:17:24 -04:00
|
|
|
require git wget curl find jq
|
2024-08-23 16:11:55 -04:00
|
|
|
|
2024-02-26 00:21:53 -05:00
|
|
|
mkdir -p "$HOME/.tmp" || exit 1
|
|
|
|
|
|
|
|
if command -v sudo &> /dev/null && ! command -v sofi &> /dev/null && ! test -f /usr/bin/sofi; then
|
2024-02-24 13:04:01 -05:00
|
|
|
echo -e '#!/bin/bash\n$HOME/.sofi.sh --launch' | sudo tee /usr/bin/sofi
|
2024-02-24 12:59:24 -05:00
|
|
|
sudo chmod +x /usr/bin/sofi
|
|
|
|
fi
|
|
|
|
|
2023-09-27 12:14:06 -04:00
|
|
|
git submodule init
|
|
|
|
git submodule update
|
2021-10-06 12:47:19 -04:00
|
|
|
|
2023-08-26 00:31:52 -04:00
|
|
|
dotdirs="$(find $FAKE_HOME -mindepth 1 -type d)"
|
2021-10-06 13:01:46 -04:00
|
|
|
|
2023-08-26 00:31:52 -04:00
|
|
|
echo "$dotdirs" | while read -r dotdir; do
|
|
|
|
new="$HOME${dotdir:${#FAKE_HOME}}"
|
2024-01-22 13:30:45 -05:00
|
|
|
if test -d "$new"; then
|
|
|
|
continue
|
|
|
|
fi
|
2023-08-26 00:31:52 -04:00
|
|
|
echo "mkdir -p $new"
|
2024-01-22 13:30:45 -05:00
|
|
|
mkdir -p "$new"
|
2023-08-26 00:31:52 -04:00
|
|
|
done
|
2021-10-07 11:29:19 -04:00
|
|
|
|
2021-10-06 13:32:36 -04:00
|
|
|
|
2023-08-26 00:31:52 -04:00
|
|
|
dotfiles="$(find $FAKE_HOME -mindepth 1 -type f)"
|
2021-10-06 13:50:04 -04:00
|
|
|
|
2023-08-26 00:31:52 -04:00
|
|
|
echo "$dotfiles" | while read -r dotfile; do
|
|
|
|
new="$HOME${dotfile:${#FAKE_HOME}}"
|
2024-01-22 13:30:45 -05:00
|
|
|
if [[ "$(realpath $dotfile)" == "$(realpath $new)" ]]; then
|
|
|
|
continue
|
|
|
|
fi
|
2023-08-26 00:31:52 -04:00
|
|
|
echo "$dotfile => $new"
|
|
|
|
ln -sf "$dotfile" "$new"
|
|
|
|
done
|
2021-10-06 13:50:04 -04:00
|
|
|
|
2024-01-20 18:23:14 -05:00
|
|
|
function add-export {
|
2024-01-25 20:54:24 -05:00
|
|
|
local final="$1\"$2\""
|
|
|
|
if grep "$final" "$HOME/.zsh_local" &> /dev/null; then
|
|
|
|
return
|
2024-01-20 18:23:14 -05:00
|
|
|
fi
|
2024-01-25 20:54:24 -05:00
|
|
|
if grep "$1" "$HOME/.zsh_local" &> /dev/null; then
|
|
|
|
echo "Replacing '$(grep "$1" "$HOME/.zsh_local")' with '$final'"
|
|
|
|
local escaped="$(echo "$1" | sed 's@/@\\/@g')"
|
|
|
|
sed -i "/$escaped/d" "$HOME/.zsh_local"
|
|
|
|
fi
|
|
|
|
echo "$final" >> "$HOME/.zsh_local"
|
2024-01-20 18:23:14 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
add-export "export DOT_DIR=" "$SCRIPT_DIR"
|
|
|
|
add-export "export f=" "$FAKE_HOME"
|
2023-12-13 15:09:02 -05:00
|
|
|
|
2023-08-26 00:31:52 -04:00
|
|
|
if [[ "$1" == "--files-only" ]]; then
|
2023-08-26 00:28:19 -04:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2023-08-26 00:44:39 -04:00
|
|
|
if ! command -v cargo &> /dev/null; then
|
2024-01-22 13:30:45 -05:00
|
|
|
echo "Rust is not installed. Installing..."
|
2023-08-26 00:28:19 -04:00
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
|
|
|
|
fi
|
|
|
|
|
|
|
|
. "$HOME/.cargo/env"
|
2023-08-26 00:44:39 -04:00
|
|
|
if command -v cargo &> /dev/null && ! command -v bat &> /dev/null; then
|
2024-01-22 13:30:45 -05:00
|
|
|
echo "Bat is not installed. Installing..."
|
2023-08-26 00:28:19 -04:00
|
|
|
cargo install bat
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! test -d "$HOME/.nvm"; then
|
2024-01-22 13:30:45 -05:00
|
|
|
echo "nvm is not installed. Installing..."
|
2023-08-26 00:28:19 -04:00
|
|
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
|
|
|
|
export NVM_DIR="$HOME/.nvm"
|
|
|
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
|
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
|
|
|
nvm install 14
|
|
|
|
nvm install 18
|
|
|
|
nvm install node
|
|
|
|
nvm use node
|
2021-10-06 13:32:36 -04:00
|
|
|
fi
|
2023-08-26 00:28:19 -04:00
|
|
|
|
2024-02-26 00:21:53 -05:00
|
|
|
if command -v sudo &> /dev/null && ! command -v dotnet &> /dev/null; then
|
2024-01-22 13:30:45 -05:00
|
|
|
echo "dotnet is not installed. Installing..."
|
2024-02-26 00:21:53 -05:00
|
|
|
wget https://dot.net/v1/dotnet-install.sh -O $HOME/.tmp/dotnet-install.sh
|
|
|
|
chmod +x $HOME/.tmp/dotnet-install.sh
|
|
|
|
$HOME/.tmp/dotnet-install.sh --version latest
|
|
|
|
rm $HOME/.tmp/dotnet-install.sh
|
2023-08-26 00:28:19 -04:00
|
|
|
fi
|
|
|
|
|
2023-08-26 00:44:39 -04:00
|
|
|
if ! command -v starship &> /dev/null; then
|
2024-01-22 13:30:45 -05:00
|
|
|
echo "starship is not installed. Installing..."
|
2023-12-13 14:00:47 -05:00
|
|
|
curl -sS https://starship.rs/install.sh | sh
|
2023-08-26 00:28:19 -04:00
|
|
|
fi
|
|
|
|
|
2023-08-26 00:44:39 -04:00
|
|
|
if ! test -d $HOME/.config/JetBrains/; then
|
2024-01-22 13:30:45 -05:00
|
|
|
echo "JetBrains toolbox is not installed. Installing..."
|
2023-08-26 00:41:41 -04:00
|
|
|
ARCHIVE_URL="$(curl -s 'https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release' | grep -Po '"linux":.*?[^\\]",' | awk -F ':' '{print $3,":"$4}'| sed 's/[", ]//g')"
|
2024-02-26 00:21:53 -05:00
|
|
|
wget -q --show-progress -cO "$HOME/.tmp/jetbrains-toolbox-latest.tar.gz" "$ARCHIVE_URL"
|
|
|
|
cd $HOME/.tmp/
|
2023-08-26 00:41:41 -04:00
|
|
|
tar -xvf jetbrains-toolbox-latest.tar.gz --strip-components=1
|
|
|
|
chmod +x jetbrains-toolbox
|
|
|
|
./jetbrains-toolbox
|
|
|
|
fi
|
|
|
|
|
2024-01-08 18:49:57 -05:00
|
|
|
mkdir -p "$HOME/.local/share/fonts"
|
|
|
|
if ! test -f "$HOME/.local/share/fonts/FiraCodeNerdFontMono-Medium.ttf"; then
|
2024-01-22 13:30:45 -05:00
|
|
|
echo "FiraCode is not installed. Installing..."
|
2024-02-26 00:21:53 -05:00
|
|
|
wget -O $HOME/.tmp/firacode.zip "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FiraCode.zip"
|
|
|
|
unzip -d "$HOME/.local/share/fonts" $HOME/.tmp/firacode.zip
|
|
|
|
rm $HOME/.tmp/firacode.zip
|
2024-01-08 18:49:57 -05:00
|
|
|
fc-cache -f -v
|
|
|
|
fi
|
|
|
|
|
2024-08-30 14:20:49 -04:00
|
|
|
if [[ "$(hostname)" != "sage-bigboy" ]]; then
|
|
|
|
curdir="$(pwd)"
|
|
|
|
cd $SCRIPT_DIR || exit 1
|
|
|
|
if test -d git-mirror-machine; then
|
|
|
|
cd git-mirror-machine
|
|
|
|
git pull
|
|
|
|
else
|
|
|
|
git clone 'https://git.sagev.space/sage/git-mirror-machine.git'
|
|
|
|
cd git-mirror-machine
|
|
|
|
fi
|
|
|
|
cd "$curdir" || exit 1
|
2024-08-29 14:19:31 -04:00
|
|
|
fi
|
|
|
|
|
2023-08-26 00:44:39 -04:00
|
|
|
if ! command -v fzf &> /dev/null; then
|
|
|
|
echo "You may wish to install fzf for sofi and other search"
|
2021-10-06 13:32:36 -04:00
|
|
|
fi
|