Automatically run getdot once a day.

Quieter copy.sh when links are already in place
This commit is contained in:
Sage Vaillancourt 2024-01-22 13:30:45 -05:00
parent 0ba2e5df3a
commit 566c1904ef
2 changed files with 25 additions and 33 deletions

49
copy.sh
View File

@ -1,5 +1,7 @@
#!/bin/bash
echo "Initializing dotfiles..."
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
FAKE_HOME="$SCRIPT_DIR/fake_home"
export f="$FAKE_HOME"
@ -16,8 +18,11 @@ dotdirs="$(find $FAKE_HOME -mindepth 1 -type d)"
echo "$dotdirs" | while read -r dotdir; do
new="$HOME${dotdir:${#FAKE_HOME}}"
if test -d "$new"; then
continue
fi
echo "mkdir -p $new"
mkdir -p $new
mkdir -p "$new"
done
@ -25,12 +30,15 @@ dotfiles="$(find $FAKE_HOME -mindepth 1 -type f)"
echo "$dotfiles" | while read -r dotfile; do
new="$HOME${dotfile:${#FAKE_HOME}}"
if [[ "$(realpath $dotfile)" == "$(realpath $new)" ]]; then
continue
fi
echo "$dotfile => $new"
ln -sf "$dotfile" "$new"
done
function add-export {
if ! grep "$1" "$HOME/.zsh_local"; then
if ! grep "$1" "$HOME/.zsh_local" &> /dev/null; then
echo "$1\"$2\"" >> "$HOME/.zsh_local"
fi
}
@ -42,25 +50,19 @@ if [[ "$1" == "--files-only" ]]; then
exit 0
fi
echo
echo "Installing required packages..."
echo -n "Rust is "
if ! command -v cargo &> /dev/null; then
echo "not installed. Installing..."
echo "Rust is not installed. Installing..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
else
echo "already installed."
fi
. "$HOME/.cargo/env"
if command -v cargo &> /dev/null && ! command -v bat &> /dev/null; then
echo "Bat is not installed. Installing..."
cargo install bat
fi
echo -n "nvm is "
if ! test -d "$HOME/.nvm"; then
echo "not installed. Installing..."
echo "nvm is not installed. Installing..."
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
@ -69,57 +71,40 @@ if ! test -d "$HOME/.nvm"; then
nvm install 18
nvm install node
nvm use node
else
echo "already installed."
fi
echo -n "dotnet is "
if ! command -v dotnet &> /dev/null; then
echo "not installed. Installing..."
echo "dotnet is not installed. Installing..."
wget https://dot.net/v1/dotnet-install.sh -O /tmp/dotnet-install.sh
chmod +x /tmp/dotnet-install.sh
/tmp/dotnet-install.sh --version latest
rm /tmp/dotnet-install.sh
else
echo "already installed."
fi
echo -n "starship is "
if ! command -v starship &> /dev/null; then
echo "not installed. Installing..."
echo "starship is not installed. Installing..."
curl -sS https://starship.rs/install.sh | sh
else
echo "already installed."
fi
echo -n "JetBrains toolbox is "
if ! test -d $HOME/.config/JetBrains/; then
echo "not installed. Installing..."
echo "JetBrains toolbox is not installed. Installing..."
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')"
wget -q --show-progress -cO "/tmp/jetbrains-toolbox-latest.tar.gz" "$ARCHIVE_URL"
cd /tmp/
tar -xvf jetbrains-toolbox-latest.tar.gz --strip-components=1
chmod +x jetbrains-toolbox
./jetbrains-toolbox
else
echo "already installed."
fi
mkdir -p "$HOME/.local/share/fonts"
echo -n "FiraCode is "
if ! test -f "$HOME/.local/share/fonts/FiraCodeNerdFontMono-Medium.ttf"; then
echo "not installed. Installing..."
echo "FiraCode is not installed. Installing..."
wget -O /tmp/firacode.zip "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FiraCode.zip"
unzip -d "$HOME/.local/share/fonts" /tmp/firacode.zip
rm /tmp/firacode.zip
fc-cache -f -v
else
echo "already installed."
fi
if ! command -v fzf &> /dev/null; then
echo "You may wish to install fzf for sofi and other search"
else
echo "fzf is already installed"
fi

View File

@ -3,7 +3,7 @@ if test -f /usr/share/doc/fzf/examples/completion.zsh &> /dev/null; then
fi
HISTFILE=~/.histfile
HISTSIZE=SAVEHIST=100000
HISTSIZE=SAVEHIST=100000000
setopt appendhistory autocd notify
setopt menu_complete
unsetopt beep
@ -91,6 +91,13 @@ if test -f ~/.cargo/env; then
source ~/.cargo/env
fi
last_get_file="/tmp/.$(whoami)-dotfiles-last-get"
current_date="$(date '+%Y-%m-%d')"
if test -d "$DOT_DIR" && [[ "$current_date" != "$(cat "$last_get_file")" ]] &> /dev/null; then
echo "$current_date" > "$last_get_file"
getdot
fi
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