Skip to content

Instantly share code, notes, and snippets.

@nipunravisara
Last active April 19, 2024 15:47
Show Gist options
  • Save nipunravisara/77cd3908fad48799011c37ba21050c63 to your computer and use it in GitHub Desktop.
Save nipunravisara/77cd3908fad48799011c37ba21050c63 to your computer and use it in GitHub Desktop.
Setup my workstation
red=`tput setaf 1`
green=`tput setaf 2`
blue=`tput setaf 6`
reset=`tput sgr0`
install_package() {
echo "$blue ⊙ Checking package $1 $reset"
if command -v $1 &> /dev/null || [ -d ".$1" ] || [ -d "$1.app" ]; then
echo "$green ✔ $1 already installed $reset"
echo "------------------------------------------------"
else
/bin/bash -c "$2";
echo "$green ✔ $1 installed $reset"
echo "------------------------------------------------"
fi
}
setup_dotfiles() {
if [ -d "$HOME/.dotfiles" ]; then
echo "$green ✔ Dotfiles are already configured $reset"
else
echo "$blue ⊙ Cleaning old dotfiles $reset"
echo "$blue ⊙ Setting up dotfiles $reset"
echo ".dotfiles" >> .gitignore
git clone --bare https://github.com/nipunravisara/dotfiles $HOME/.dotfiles
rm -rf ~/.config
echo "$blue ⊙ ~/.config removed $reset"
rm -rf ~/.local
echo "$blue ⊙ ~/.local removed $reset"
rm -rf ~/.zshrc
echo "$blue ⊙ ~/.zshrc removed $reset"
rm -rf ~/.gitconfig
echo "$blue ⊙ ~/.gitconfig removed $reset"
rm -rf ~/.zprofile
echo "$blue ⊙ ~/.zprofile removed $reset"
rm -rf ~/.gitignore
echo "$blue ⊙ ~/.gitignore removed $reset"
rm -rf ~/README.md
echo "$blue ⊙ ~/README.md removed $reset"
/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME checkout
/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME config --local status.showUntrackedFiles no
echo "$green ✔ Dotfiles configured. $reset"
fi
}
post_installation_setup() {
echo "$blue ⊙ Linking dotfiles $reset"
ln -s .config/zsh/zshrc ~/.zshrc
ln -s .config/zsh/zprofile ~/.zprofile
ln -s .config/git/gitconfig ~/.gitconfig
echo "------------------------------------------------"
echo "$blue ⊙ Downloading fonts $reset"
if [ ! -e ~/Library/Fonts/JetBrainsMonoNerdFontMono-Regular.ttf ]
then
cd ~/Library/Fonts && curl -fLO https://github.com/ryanoasis/nerd-fonts/raw/HEAD/patched-fonts/JetBrainsMono/Ligatures/Regular/JetBrainsMonoNerdFontMono-Regular.ttf && cd
fi
if [ ! -e ~/Library/Fonts/JetBrainsMonoNerdFontMono-Italic.ttf ]
then
cd ~/Library/Fonts && curl -fLO https://github.com/ryanoasis/nerd-fonts/raw/HEAD/patched-fonts/JetBrainsMono/Ligatures/Italic/JetBrainsMonoNerdFontMono-Italic.ttf && cd
fi
if [ ! -e ~/Library/Fonts/JetBrainsMonoNerdFontMono-Bold.ttf ]
then
cd ~/Library/Fonts && curl -fLO https://github.com/ryanoasis/nerd-fonts/raw/HEAD/patched-fonts/JetBrainsMono/Ligatures/Bold/JetBrainsMonoNerdFontMono-Bold.ttf && cd
fi
echo "------------------------------------------------"
echo "$blue ⊙ Install tmux plugin manager $reset"
if [ -d ~/.tmux/plugins/tpm ]; then
echo "Tmux plugin manager already installed"
else
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
echo "------------------------------------------------"
# echo "$blue ⊙ Install neovim plugin manager(packer) $reset"
# if [ -d ~/.local/share/nvim/site/pack/packer/start/packer.nvim ]; then
# echo "Neovim plugin manager already installed"
# else
# git clone --depth 1 https://github.com/wbthomason/packer.nvim\
# ~/.local/share/nvim/site/pack/packer/start/packer.nvim
# fi
# echo "------------------------------------------------"
# echo "$blue ⊙ Starting services $reset"
# skhd --install-service
# skhd --start-service
# yabai --install-service
# yabai --start-service
# echo "------------------------------------------------"
}
setup_wall_color_scheme() {
echo "$blue ⊙ Setting up wallpaper and color scheme $reset"
pip3 install pywal
if [ -d ~/.local/alacritty-color-export ]; then
wal -i .local/wallpapers/storm.jpeg
chmod +x ~/.local/alacritty-color-export/script.sh
~/.local/alacritty-color-export/script.sh ~/.config/alacritty/colors.yml
else
git clone https://github.com/egeesin/alacritty-color-export ~/.local/alacritty-color-export
chmod +x ~/.local/alacritty-color-export/script.sh
fi
}
install_package "brew" "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo "export PATH=/opt/homebrew/bin:$PATH" >> .zprofile
install_package "oh-my-zsh" "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh) --unattended"
install_package "nvm" "$(curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash)"
install_package "ripgrep" "brew install ripgrep"
install_package "Visual Studio Code" "brew install --cask visual-studio-code"
install_package "alacritty" "brew install --cask alacritty"
install_package "Google Chrome" "brew install --cask google-chrome"
install_package "python" "brew install python"
install_package "tmux" "brew install tmux"
install_package "python" "brew install python"
install_package "imagemagick" "brew install imagemagick"
setup_dotfiles
post_installation_setup
setup_wall_color_scheme
echo "\n\n\n"
echo "$green Your PC is ready to use. $reset"
echo "\n\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment