theme and scripts

This commit is contained in:
Harivansh Rathi 2026-03-20 14:22:40 -04:00
parent deade2bafb
commit 7ae7c1ceec
17 changed files with 575 additions and 270 deletions

View file

@ -13,6 +13,7 @@
./migration.nix
./nvim.nix
./rectangle.nix
./scripts.nix
./tmux.nix
./zsh.nix
];

View file

@ -1,11 +1,11 @@
{ pkgs, ... }:
let
{
config,
pkgs,
...
}: let
theme = import ../lib/theme.nix {inherit config;};
ghosttyConfig = ''
theme = "Gruvbox Material Dark"
background = #181818
cursor-color = #ddc7a1
selection-background = #504945
selection-foreground = #ebdbb2
theme = "dark:cozybox-dark,light:cozybox-light"
font-family = Berkeley Mono
font-codepoint-map = U+f101-U+f25c=nonicons
background-opacity = 1
@ -38,12 +38,6 @@ let
keybind = vim/i=deactivate_key_table
keybind = vim/catch_all=ignore
mouse-hide-while-typing = true
palette = 2=#8ec97c
palette = 10=#8ec97c
palette = 4=#4672d4
palette = 12=#4672d4
palette = 6=#8ec07c
palette = 14=#8ec07c
macos-titlebar-style = hidden
macos-option-as-alt = true
confirm-close-surface = true
@ -67,6 +61,9 @@ in {
force = true;
};
xdg.configFile."ghostty/themes/cozybox-dark".text = theme.renderGhostty "dark";
xdg.configFile."ghostty/themes/cozybox-light".text = theme.renderGhostty "light";
home.file."Library/Application Support/com.mitchellh.ghostty/config.ghostty" = {
text = ghosttyConfig;
force = true;

33
home/scripts.nix Normal file
View file

@ -0,0 +1,33 @@
{
config,
lib,
pkgs,
...
}: let
customScripts = import ../scripts {inherit config lib pkgs;};
in {
home.packages = builtins.attrValues customScripts.packages;
home.activation.initializeThemeState = lib.hm.dag.entryAfter ["writeBoundary"] ''
mkdir -p "${customScripts.theme.paths.stateDir}" "${customScripts.theme.paths.tmuxDir}"
if [[ -f "${customScripts.theme.paths.stateFile}" ]]; then
mode=$(tr -d '[:space:]' < "${customScripts.theme.paths.stateFile}")
else
mode="${customScripts.theme.defaultMode}"
printf '%s\n' "$mode" > "${customScripts.theme.paths.stateFile}"
fi
case "$mode" in
light)
tmux_target="${customScripts.tmuxConfigs.light}"
;;
*)
printf '%s\n' "${customScripts.theme.defaultMode}" > "${customScripts.theme.paths.stateFile}"
tmux_target="${customScripts.tmuxConfigs.dark}"
;;
esac
ln -sfn "$tmux_target" "${customScripts.theme.paths.tmuxCurrentFile}"
'';
}

View file

@ -1,4 +1,11 @@
{lib, pkgs, ...}: {
{
config,
lib,
pkgs,
...
}: let
theme = import ../lib/theme.nix {inherit config;};
in {
programs.tmux = {
enable = true;
plugins = with pkgs.tmuxPlugins; [
@ -75,54 +82,14 @@
# Disable waiting time when pressing escape, for smoother Neovim usage.
set-option -s escape-time 0
# Styling
RED="#ea6962"
GREEN="#8ec97c"
YELLOW="#d8a657"
BLUE="#4672d4"
MAGENTA="#d3869b"
CYAN="#89b482"
BLACK="#1d2021"
DARK_GRAY="#181818"
LIGHT_GRAY="#4F4946"
# Match Ghostty theme (cozybox-override palette + Gruvbox Material Dark base)
BG="#181818"
FG="#d4be98"
HALF_ROUND_OPEN="#(printf '\uE0B2')"
HALF_ROUND_CLOSE="#(printf '\uE0B0')"
TRIANGLE_OPEN="#(printf '\uE0B2')"
TRIANGLE_CLOSE="#(printf '\uE0B0')"
set-option -g prompt-cursor-colour default
set-option -g status-position bottom
set-option -g status-style bg=''${BG},fg=''${FG}
set-option -g status-justify left
set-option -g status-left ""
set-option -g status-right "#(~/.config/tmux/session-list.sh)"
set-option -g status-left-length 100
set-option -g status-right-length 100
set-option -g window-status-format "\
\
#I\
#[fg=''${MAGENTA}]:\
#[fg=default]#W\
\
"
set-option -g window-status-current-format "\
\
#[fg=''${MAGENTA}]*#[fg=default]#I\
#[fg=''${MAGENTA}]:\
#[fg=default]#W\
\
"
set-option -g window-status-separator ""
set-option -g pane-border-style fg=''${BG}
set-option -g pane-active-border-style fg=''${BG}
source-file "${theme.paths.tmuxCurrentFile}"
'';
};
@ -131,9 +98,10 @@
text = ''
#!/bin/sh
current=$(tmux display-message -p '#S')
accent=$(tmux show -gv @cozybox-accent 2>/dev/null || printf '#d3869b')
tmux list-sessions -F '#S' | while IFS= read -r s; do
if [ "$s" = "$current" ]; then
printf ' #[fg=#d3869b]*#[fg=default]%s ' "$s"
printf ' #[fg=%s]*#[fg=default]%s ' "$accent" "$s"
else
printf ' %s ' "$s"
fi

View file

@ -41,11 +41,11 @@
tailscale = "/Applications/Tailscale.app/Contents/MacOS/Tailscale";
# nix helpers
nr = "nix profile remove"; # nr <index> - remove from profile
ns = "nix search nixpkgs"; # ns <query> - search packages
nls = "nix profile list"; # nls - list installed profile packages
nrb = "sudo darwin-rebuild switch --flake ~/Documents/GitHub/nix"; # nrb - rebuild declarative config
nup = "nix flake update ~/Documents/GitHub/nix && sudo darwin-rebuild switch --flake ~/Documents/GitHub/nix"; # nup - update flake + rebuild
nr = "nix profile remove"; # nr <index> - remove from profile
ns = "nix search nixpkgs"; # ns <query> - search packages
nls = "nix profile list"; # nls - list installed profile packages
nrb = "sudo darwin-rebuild switch --flake ~/Documents/GitHub/nix"; # nrb - rebuild declarative config
nup = "nix flake update ~/Documents/GitHub/nix && sudo darwin-rebuild switch --flake ~/Documents/GitHub/nix"; # nup - update flake + rebuild
};
envExtra = ''
@ -108,16 +108,7 @@
$path
)
ni() { nix profile add "nixpkgs#$1"; }
unalias ga 2>/dev/null
ga() {
if [[ $# -eq 0 ]]; then
git add .
else
git add "$@"
fi
}
git() {
command git "$@"
@ -169,136 +160,9 @@
_codex_set_cursor beam
}
iosrun() {
local project=$(find . -maxdepth 1 -name "*.xcodeproj" | head -1)
local scheme=$(basename "$project" .xcodeproj)
local derived=".derived-data"
local sim_name="''${1:-iPhone 16e}"
if [[ -z "$project" ]]; then
echo "No .xcodeproj found in current directory"
return 1
fi
echo "Building $scheme..."
if ! xcodebuild -project "$project" -scheme "$scheme" \
-destination "platform=iOS Simulator,name=$sim_name" \
-derivedDataPath "$derived" build -quiet; then
echo "Build failed"
return 1
fi
echo "Build succeeded. Launching simulator..."
xcrun simctl boot "$sim_name" 2>/dev/null
open -a Simulator
local app_path="$derived/Build/Products/Debug-iphonesimulator/$scheme.app"
local bundle_id=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$app_path/Info.plist")
echo "Installing $scheme..."
while ! xcrun simctl install "$sim_name" "$app_path" 2>/dev/null; do
sleep 0.5
done
echo "Launching $bundle_id..."
while ! xcrun simctl launch "$sim_name" "$bundle_id" 2>&1 | grep -q "$bundle_id"; do
sleep 0.5
done
echo "Launched $bundle_id - streaming logs (Ctrl+C to stop)"
echo "----------------------------------------"
xcrun simctl spawn "$sim_name" log stream \
--predicate "(subsystem CONTAINS '$bundle_id' OR process == '$scheme') AND NOT subsystem BEGINSWITH 'com.apple'" \
--style compact \
--color always 2>/dev/null | while read -r line; do
if [[ "$line" == *"error"* ]] || [[ "$line" == *"Error"* ]]; then
echo "\033[31m$line\033[0m"
elif [[ "$line" == *"warning"* ]] || [[ "$line" == *"Warning"* ]]; then
echo "\033[33m$line\033[0m"
else
echo "$line"
fi
done
}
mdview() {
markserv "$1"
}
if command -v wt >/dev/null 2>&1; then
eval "$(command wt config shell init zsh)"
fi
wtc() { wt switch --create --base @ "$@"; }
unalias gpr 2>/dev/null
gpr() {
while true; do
local pr=$(gh pr list --limit 50 \
--json number,title,author,headRefName \
--template '{{range .}}#{{.number}} {{.title}} ({{.author.login}}) [{{.headRefName}}]{{"\n"}}{{end}}' \
| fzf --preview 'gh pr view {1} --comments' \
--preview-window=right:60%:wrap \
--header 'enter: view | ctrl-m: merge | ctrl-x: close | ctrl-o: checkout | ctrl-b: browser' \
--bind 'ctrl-o:execute(gh pr checkout {1})' \
--bind 'ctrl-b:execute(gh pr view {1} --web)' \
--expect=ctrl-m,ctrl-x,enter)
[[ -z "$pr" ]] && return
local key=$(echo "$pr" | head -1)
local selection=$(echo "$pr" | tail -1)
local num=$(echo "$selection" | grep -o '#[0-9]*' | tr -d '#')
[[ -z "$num" ]] && return
case "$key" in
ctrl-m)
echo "Merge PR #$num? (y/n)"
read -q && gh pr merge "$num" --merge
echo
;;
ctrl-x)
echo "Close PR #$num? (y/n)"
read -q && gh pr close "$num"
echo
;;
enter|"")
gh pr view "$num"
;;
esac
done
}
ghpr() {
local base=$(git rev-parse --abbrev-ref HEAD)
local upstream="''${1:-main}"
local remote_ref="origin/$upstream"
local unpushed=$(git log "$remote_ref"..HEAD --oneline 2>/dev/null)
if [[ -z "$unpushed" ]]; then
if git diff --cached --quiet; then
echo "No unpushed commits and no staged changes"
return 1
fi
echo "No unpushed commits, but staged changes found. Opening commit dialog..."
git commit || return 1
fi
local msg=$(git log "$remote_ref"..HEAD --format='%s' --reverse | head -1)
local branch=$(echo "$msg" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//')
git checkout -b "$branch"
git checkout "$base"
git reset --hard "$remote_ref"
git checkout "$branch"
git push -u origin "$branch"
gh pr create --base "$upstream" --fill --web 2>/dev/null || gh pr create --base "$upstream" --fill
gh pr view "$branch" --json url -q '.url'
}
'')
(lib.mkAfter ''