2022-09-13 23:08:01 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2023-11-11 11:55:25 -05:00
|
|
|
readonly PROGNAME=$(basename $0)
|
|
|
|
readonly PROGDIR=$(readlink -m $(dirname $0))
|
|
|
|
readonly ARGS="$@"
|
|
|
|
|
2022-09-13 23:08:01 -04:00
|
|
|
install_homebrew() {
|
2023-11-10 20:57:01 -05:00
|
|
|
echo -n Checking homebrew...
|
|
|
|
if command -v brew > /dev/null; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing...
|
2022-09-13 23:08:01 -04:00
|
|
|
NONINTERACTIVE=1 /bin/bash -c "$(
|
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
--location \
|
|
|
|
--show-error \
|
|
|
|
--silent \
|
|
|
|
https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
|
|
|
|
)"
|
|
|
|
fi
|
2023-11-10 20:57:01 -05:00
|
|
|
echo done
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
2023-11-10 20:57:01 -05:00
|
|
|
install_shared_brew_packages() {
|
|
|
|
echo -n Checking shared brew packages...
|
|
|
|
missing_packages=$(
|
|
|
|
comm -23 <(cat packages-shared-brew.txt) <(brew list | sort) \
|
|
|
|
| tr "\n" " "
|
|
|
|
)
|
2022-09-13 23:08:01 -04:00
|
|
|
|
2023-11-10 20:57:01 -05:00
|
|
|
if [[ -z $missing_packages ]]; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing $missing_packages...
|
|
|
|
brew install $missing_packages
|
|
|
|
fi
|
|
|
|
echo done
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
install_alacritty() {
|
2023-11-10 20:57:01 -05:00
|
|
|
echo -n Checking Alacritty...
|
|
|
|
if command -v alacritty > /dev/null; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing...
|
2022-09-13 23:08:01 -04:00
|
|
|
cargo install alacritty
|
|
|
|
|
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
--location \
|
|
|
|
--output /tmp/Alacritty.svg \
|
|
|
|
https://raw.githubusercontent.com/alacritty/alacritty/master/extra/logo/alacritty-term.svg
|
|
|
|
|
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
--location \
|
|
|
|
--output /tmp/Alacritty.desktop \
|
|
|
|
https://raw.githubusercontent.com/alacritty/alacritty/master/extra/linux/Alacritty.desktop
|
|
|
|
|
|
|
|
sudo mv /tmp/Alacritty.svg /usr/share/pixmaps/Alacritty.svg
|
|
|
|
sudo desktop-file-install /tmp/Alacritty.desktop
|
|
|
|
sudo update-desktop-database
|
2022-12-10 09:44:53 -05:00
|
|
|
sudo ln -s /home/$USER/.cargo/bin/alacritty /usr/local/bin/alacritty
|
2022-09-13 23:08:01 -04:00
|
|
|
fi
|
2023-11-10 20:57:01 -05:00
|
|
|
echo done
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
install_alacritty_terminfo() {
|
2023-11-10 20:57:01 -05:00
|
|
|
echo -n Checking Alacritty terminfo...
|
|
|
|
if infocmp alacritty > /dev/null; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing...
|
2022-09-13 23:08:01 -04:00
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
--location \
|
|
|
|
--output /tmp/alacritty.info \
|
|
|
|
https://raw.githubusercontent.com/alacritty/alacritty/master/extra/alacritty.info
|
|
|
|
|
|
|
|
sudo tic -xe alacritty,alacritty-direct /tmp/alacritty.info
|
2022-12-10 09:27:25 -05:00
|
|
|
fi
|
2023-11-10 20:57:01 -05:00
|
|
|
echo done
|
2022-12-10 09:27:25 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
install_tmux_terminfo() {
|
2023-11-10 20:57:01 -05:00
|
|
|
echo -n Checking Tmux terminfo...
|
|
|
|
if infocmp tmux-256color > /dev/null; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installling....
|
2022-12-10 09:27:25 -05:00
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
--location \
|
|
|
|
--output /tmp/tmux-256color.src.gz \
|
|
|
|
https://invisible-island.net/datafiles/current/terminfo.src.gz
|
|
|
|
|
|
|
|
pushd /tmp
|
|
|
|
gunzip tmux-256color.src.gz
|
2022-12-10 09:56:54 -05:00
|
|
|
sed -i 's/pairs#0x10000/pairs#32767/g' tmux-256color.src
|
2022-12-10 09:27:25 -05:00
|
|
|
|
|
|
|
sudo tic -xe tmux-256color tmux-256color.src
|
|
|
|
popd
|
2022-09-13 23:08:01 -04:00
|
|
|
fi
|
2023-11-10 20:57:01 -05:00
|
|
|
echo done
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
2022-11-22 20:26:02 -05:00
|
|
|
install_fzf() {
|
2023-11-10 20:57:01 -05:00
|
|
|
echo -n Checking fzf...
|
|
|
|
if [[ $PATH =~ "fzf" ]]; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing...
|
|
|
|
$(brew --prefix)/opt/fzf/install \
|
|
|
|
--xdg \
|
|
|
|
--no-update-rc \
|
|
|
|
--key-bindings \
|
|
|
|
--completion
|
|
|
|
fi
|
|
|
|
echo done
|
2022-11-22 20:26:02 -05:00
|
|
|
}
|
|
|
|
|
2022-09-13 23:08:01 -04:00
|
|
|
install_rust() {
|
2023-11-10 20:57:01 -05:00
|
|
|
echo -n Checking Rust...
|
|
|
|
if command -v rustup > /dev/null; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing...
|
2022-09-13 23:08:01 -04:00
|
|
|
curl \
|
|
|
|
--fail \
|
|
|
|
--proto '=https' \
|
|
|
|
--show-error \
|
|
|
|
--silent \
|
|
|
|
--tlsv1.2 \
|
|
|
|
https://sh.rustup.rs \
|
|
|
|
| sh -s -- -y --no-modify-path
|
|
|
|
fi
|
2023-11-10 20:57:01 -05:00
|
|
|
echo done
|
|
|
|
}
|
|
|
|
|
|
|
|
install_linux_packagges() {
|
|
|
|
echo -n Checking Linux packages...
|
|
|
|
packages=$(cat packages-linux-apt.txt | tr "\n" " ")
|
|
|
|
if dpkg -s $packages >/dev/null 2>&1; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing...
|
|
|
|
sudo apt-get install --assume-yes $packages
|
|
|
|
fi
|
|
|
|
echo done
|
|
|
|
}
|
|
|
|
|
|
|
|
install_darwin_brew_packages() {
|
|
|
|
echo -n Checking Darwin brew packages...
|
|
|
|
missing_packages=$(
|
|
|
|
comm -23 <(cat packages-darwin-brew.txt) <(brew list | sort) \
|
|
|
|
| tr "\n" " "
|
|
|
|
)
|
|
|
|
|
|
|
|
if [[ -z $missing_packages ]]; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing $missing_packages...
|
|
|
|
brew install --cask $missing_packages
|
|
|
|
fi
|
|
|
|
echo done
|
|
|
|
}
|
|
|
|
|
|
|
|
install_darwin_brew_cask_packages() {
|
|
|
|
echo -n Checking Darwin brew cask packages...
|
2023-11-11 11:55:25 -05:00
|
|
|
package_files="packages-darwin-brew-cask.txt"
|
|
|
|
if [[ $ARGS == "personal" ]]; then
|
|
|
|
package_files+=" packages-darwin-brew-cask-personal.txt"
|
|
|
|
fi
|
|
|
|
if [[ $ARGS == "work" ]]; then
|
|
|
|
package_files+=" packages-darwin-brew-cask-work.txt"
|
|
|
|
fi
|
|
|
|
|
2023-11-10 20:57:01 -05:00
|
|
|
missing_packages=$(
|
2023-11-11 11:55:25 -05:00
|
|
|
comm -23 <(cat $package_files | sort) <(brew list | sort) \
|
2023-11-10 20:57:01 -05:00
|
|
|
| tr "\n" " "
|
|
|
|
)
|
|
|
|
|
|
|
|
if [[ -z $missing_packages ]]; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing $missing_packages...
|
|
|
|
brew install --cask $missing_packages
|
|
|
|
fi
|
|
|
|
echo done
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
2023-11-10 20:57:01 -05:00
|
|
|
install_color_default() {
|
|
|
|
echo -n Checking color default file...
|
|
|
|
if [[ -f $HOME/.config/atomaka/color.yml ]]; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installing....
|
|
|
|
$HOME/dotfiles/bin/bin/toggle-color-mode
|
2022-09-13 23:08:01 -04:00
|
|
|
fi
|
2023-11-10 20:57:01 -05:00
|
|
|
echo done
|
|
|
|
}
|
|
|
|
|
|
|
|
install_darwin_profile_hack() {
|
|
|
|
echo -n Checking profile hack...
|
|
|
|
if [[ ! -f /etc/zprofile ]]; then
|
|
|
|
echo -n already installled...
|
|
|
|
else
|
|
|
|
echo -n installing...
|
|
|
|
sudo mv /etc/{zprofile,zprofile.old}
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_env() {
|
|
|
|
echo -n Checking zshenv available...
|
|
|
|
if [[ -z $HOMEBREW_PREFIX ]]; then
|
|
|
|
echo -n already installed...
|
|
|
|
else
|
|
|
|
echo -n installling...
|
|
|
|
source ~/dotfiles/zsh/.zshenv
|
|
|
|
fi
|
|
|
|
echo done
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
install_linux() {
|
|
|
|
if ! command -v apt-get > /dev/null; then
|
2022-09-14 09:12:16 -04:00
|
|
|
echo apt-get is required, but not available
|
2022-09-13 23:08:01 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-11-10 20:57:01 -05:00
|
|
|
install_linux_packagges
|
2022-09-13 23:08:01 -04:00
|
|
|
install_homebrew
|
2023-11-10 20:57:01 -05:00
|
|
|
install_env
|
|
|
|
install_shared_brew_packages
|
|
|
|
install_fzf
|
|
|
|
install_rust
|
2022-09-13 23:08:01 -04:00
|
|
|
install_alacritty
|
2022-12-10 09:27:25 -05:00
|
|
|
install_alacritty_terminfo
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
install_darwin() {
|
2023-11-10 20:57:01 -05:00
|
|
|
install_darwin_profile_hack
|
2022-09-13 23:08:01 -04:00
|
|
|
install_homebrew
|
2023-11-10 20:57:01 -05:00
|
|
|
install_env
|
|
|
|
install_shared_brew_packages
|
|
|
|
install_fzf
|
|
|
|
install_rust
|
2022-12-10 09:27:25 -05:00
|
|
|
softwareupdate --install-rosetta --agree-to-license
|
2023-11-10 20:57:01 -05:00
|
|
|
install_darwin_brew_packages
|
|
|
|
install_darwin_brew_cask_packages
|
2022-12-10 09:27:25 -05:00
|
|
|
install_tmux_terminfo
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
os=$(uname | tr '[:upper:]' '[:lower:]')
|
|
|
|
case $os in
|
|
|
|
linux | darwin)
|
|
|
|
install_$os
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo $os not supported
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2022-11-02 12:17:19 -04:00
|
|
|
stow alacritty bin git nvim ruby tmux zsh
|
2022-12-10 09:27:25 -05:00
|
|
|
|
2023-11-10 20:57:01 -05:00
|
|
|
install_color_default
|
2022-09-13 23:08:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
main
|