Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate installation #2

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ These are my personal dotfiles.
I'm using [Wezterm](https://wezfurlong.org/wezterm/index.html) as a terminal emulator and [Neovim](https://neovim.io/) as a text editor.
My dotfiles live in a bare git repository with `$HOME` as the worktree. It's inspired by [this blog article](https://www.atlassian.com/git/tutorials/dotfiles).

## Install instructions
**Table of Contents**
* [Install instructions MacOS](#install-instructions-macos)
* [Install instructions Arch Linux](#install-instructions-arch-linux)
* [Rails dev related setup](#rails-dev-related-setup)

## Install instructions MacOS
### General
1. Install wezterm
E.g.
Expand Down Expand Up @@ -69,7 +74,15 @@ In order for telescope to work, you'll need to install ripgrep
```
yay ripgrep
```
### Rails dev related setup

## Install instructions Arch Linux

1. `git clone [email protected]:kongrei/.cfg.git`
1. `cd .cfg`
1. `chmod +x arch-linux-install.sh`
1. `chmod +x arch-linux-install.sh`

## Rails dev related setup
1. Install ruby
Install ruby-install
```
Expand Down
71 changes: 71 additions & 0 deletions arch-linux-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/bash
DOTFILES="$HOME/.cfg"

# Check if yay is installed
if ! command -v yay &> /dev/null; then
echo "yay is not installed. install it first :)"
exit 1
fi

# Checks whether a package is installed. If not installs it.
check_and_install() {
local package="$1"
if ! yay -Q "$package" &> /dev/null; then
echo "$package is not installed. Installing ..."
yay -S --noconfirm "$package"
else
echo "$package is already installed."
fi
}

# Checks whether files/dirs/symlinks exist already, deletes them if so.
link_dotfile() {
local src = "$1"
local dest= "$2"
if [ -e "$dest" ] || [ -L "$dest" ]; then
echo "Removing existing $dest"
rm -rf "$dest"
fi
echo "Creating symlink for $dest"
ln -sf "$src" "$dest"
}

# terminal emulator
check_and_install "wezterm"
# neovim and dependencies
check_and_install "ripgrep"
check_and_install "xclip"
check_and_install "neovim"
# zsh
check_and_install "zsh"

# Set zsh as default shell
if [ "$SHELL" != "/bin/zsh"]; then
echo "Setting zsh as default shell."
chsh -s $(which zsh)
fi

# Check whether oh-my-zsh is installed:

if [ ! -d "$HOME/.oh-my-zsh" ]; then
echo "Oh My Zsh is not installed. Installing..."
# Save current .zshrc if it exists
if [ -f "$HOME/.zshrc" ]; then
mv "$HOME/.zshrc" "$HOME/.zshrc.pre-oh-my-zsh"
fi

# Install Oh My Zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended

# Remove the default .zshrc created by Oh My Zsh if it exists
if [ -f "$HOME/.zshrc" ]; then
rm "$HOME/.zshrc"
fi
else
echo "Oh My Zsh is already installed"
fi

# Create symlinks
link_dotfile "$DOTFILES/.wezterm" "$HOME/.wezterm"
link_dotfile "$DOTFILES/.zshrc" "$HOME/.zshrc"
link_dotfile "$DOTFILES/.config/nvim" "$HOME/.config/nvim"