dots/conf.sh

68 lines
1.7 KiB
Bash
Executable file

#! /bin/sh
# basic scripts in for managing dotfiles and minor system tasks
update_packages() {
echo "updating packages"
# brew
if [ -f /opt/homebrew/bin/brew ]; then
echo "homebrew detected, updating..."
/opt/homebrew/bin/brew update
/opt/homebrew/bin/brew upgrade
fi
# pkg (termux)
if which pkg > /dev/null; then
echo "pkg detected, updating..."
pkg update -y
pkg upgrade -y
fi
# nix flake
if which nix > /dev/null; then
echo "nix detected, updating..."
nix flake update
git commit flake.lock -m "nix: update flake sources to $(nix flake metadata --json | jq '.locks.nodes.nixpkgs.locked.rev' --raw-output | cut -c1-7)"
# rebuild and switch for nix and darwin systems
if which nixos-rebuild > /dev/null; then
echo "detected nixos system, rebuilding..."
sudo nixos-rebuild switch --flake .
elif which darwin-rebuild > /dev/null; then
echo "detected darwin system, rebuilding..."
darwin-rebuild switch --flake .
else
echo "didn't detect a nixos or darwin system, continuing..."
fi
fi
}
install_termux() {
pkg update -y
pkg upgrade -y
pkg install -y zsh openssh stow neovim zoxide tealdeer file htop jq fzf ripgrep wget ffmpeg imagemagick unzip unar bat ani-cli tmux which
cd "$HOME/dots"
stow stow
echo '#!/data/data/com.termux/files/usr/bin/sh
termux-wake-lock
sshd' > /data/data/com.termux/files/home/.termux/boot
chsh -s zsh
echo "done!"
}
HELPTEXT="$0
usage:
update update packages on your system
install-termux update packages on your system"
if [ "$1" = "update" ]; then
update_packages
elif [ "$1" = "install-termux" ]; then
install_termux
else
echo "$HELPTEXT"
fi