Buy my course: Security for Rails Developers.
Typecraft made a really good video about how he customizes Omarchy with a set of bash scripts, so he can replicate his setup easily on new machines. While his approach is good, I chose a different one to achieve the same goal. Bash is fine, but let’s be honest, Ruby is a much better language to work with, and since Ruby is installed on Omarchy anyways, I decided to script my setup with Ruby.
I created a setup.rb file with the following contents:
@home = ENV['HOME']
Dir.glob('install*').each do |file|
load "./#{file}"
end
What I do here is, I set an instance variable to the user’s home dfirectory to
save some typing down the line, then I load all ruby files starting with
install from the directory. I will add the installation steps in those files
nicely separated.For instance to setup my dotfiles, I create an
install-dotfiles.rb file:
require 'fileutils'
`yay -S --noconfirm --needed stow` unless system('pacman -Qi "stow" &> /dev/null')
repo_url = 'https://github.com/gregmolnar/dotfiles'
current_directory = FileUtils.pwd
FileUtils.cd("#{@home}/git")
if File.exist?('dotfiles')
puts "Dotfiles repository already exists"
else
`git clone #{repo_url}`
end
puts "Removing old dotfiles"
FileUtils.rm_rf(["#{@home}/.config/alacritty", "#{@home}/.config/ghostty", "#{@home}/.config/nvim", "#{@home}/.zshrc", "#{@home}/.config/hypr/overrides.conf"])
FileUtils.cd("#{@home}/git/dotfiles")
`stow -t ~ alacritty`
`stow -t ~ ghostty`
`stow -t ~ nvim`
`stow -t ~ zsh`
`stow -t ~ omarchy`
FileUtils.cd(current_directorrequire 'fileutils'
repo_url = 'https://github.com/gregmolnar/dotfiles'
current_directory = FileUtils.pwd
FileUtils.cd("#{@home}/git")
if File.exist?('dotfiles')
puts "Dotfiles repository already exists"
else
`git clone #{repo_url}`
end
puts "Removing old dotfiles"
FileUtils.rm_rf(["#{@home}/.config/alacritty", "#{@home}/.config/ghostty", "#{@home}/.config/nvim", "#{@home}/.zshrc"])
FileUtils.cd("#{@home}/git/dotfiles")
`stow -t ~ alacritty`
`stow -t ~ ghostty`
`stow -t ~ nvim`
`stow -t ~ zsh`
`stow -t ~ omarchy`
FileUtils.cd(current_directory)y)
In this file, I install stow unless it is already installed, then I use FileUtils to change to my git directory, in case I don’t have the repository, I clone it, then I remove any existing config files and use stow to symlink the config files from my dotfiles repository and finally I change back to the starting directory.
From my dotfiles, you can see that I use zsh, but Omarchy comes wiuth bash by
default, so I need to install and setup zsh as well. For that I create an
install-zsh.rb file:
if ENV['SHELL'] == '/usr/bin/zsh'
puts "You are already using zsh"
else
`yay -S --noconfirm --needed zsh`
`chsh -s /usr/bin/zsh`
end
In this file, I check if the current shell is zsh, and if it is not I install it and change my shell to it.
The next step is to change some Omarchy defaults. For this, I have a hyprland config file to override some defaults, like changing some keybindings. This file needs to be loaded in the hyprland config file, so I created an install script for that:
config_line = "source = ~/.config/hypr/overrides.conf"
config_file = "#{@home}/.config/hypr/hyprland.conf"
if File.read(config_file).match?(config_line)
puts "Omarchy overrides already loaded"
else
puts "Adding Omarchy overrides loaded"
File.write(config_file, config_line, mode: 'a+')
end
I check if the line to load the config file already exists in the hyprland config and if it isn’t, I append it to it.
I have a few more install scripts to install tools like nmap, Burp Suite, ProtonVPN, etc, but I think the above examples are enough to demonstrate the idea behind my customization strategy and you can use the same in case you want a reproducible way to customize an Omarchy installation.
Or follow me on Twitter
I run an indie startup providing vulnerability scanning for your Ruby on Rails app.
It is free to use at the moment, and I am grateful for any feedback about it.If you would like to give it a spin, you can do it here: Vulnerability Scanning for your Ruby on Rails app!