replace the old dotfiles with the sakura line rice

The bare $HOME repo is gone. This is now the rice: install.sh, rice-*
scripts in bin/, configs in home/ linked into $HOME, theme templates, st
and the particle wallpaper. Clone to ~/rice and run install.sh.
This commit is contained in:
Sarthak 2026-09-14 16:12:09 +05:30
commit 7f41cf7a82
104 changed files with 8077 additions and 0 deletions

View file

@ -0,0 +1,22 @@
# Sakura Line - aliases. Personal ones belong in ~/.bashrc.local.
if command -v eza >/dev/null; then
alias ls='eza -lh --group-directories-first --icons=auto'
alias lsa='ls -a'
alias lt='eza --tree --level=2 --long --icons --git'
alias lta='lt -a'
fi
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias g='git'
alias gs='git status -sb'
alias gcm='git commit -m'
alias gcam='git commit -a -m'
alias gcad='git commit -a --amend'
alias d='docker'
alias t='tmux attach || tmux new -s work'
alias decompress='tar -xzf'

View file

@ -0,0 +1,18 @@
# Sakura Line - everyday functions.
# ff: fuzzy-find a file below the current directory, with a preview (pictures
# show inline in st and kitty). eff opens the pick in $EDITOR.
ff() { fzf --preview 'rice-preview {}' --preview-window 'right,55%' "$@"; }
eff() { local f; f=$(ff) && [[ -n $f ]] && "$EDITOR" "$f"; }
# img <picture>...: show pictures right in the terminal.
img() { local f; for f in "$@"; do rice-preview "$f"; done; }
# open <file|url>: open with the default app, detached from the terminal.
open() { xdg-open "$@" >/dev/null 2>&1 & disown; }
# n: nvim, on the current directory when given nothing.
n() { if (( $# == 0 )); then nvim .; else nvim "$@"; fi; }
# compress <file|dir>: make <name>.tar.gz next to it (decompress is tar -xzf).
compress() { tar -czf "${1%/}.tar.gz" "${1%/}"; }

View file

@ -0,0 +1,24 @@
# Sakura Line - git worktree helpers.
# ga <branch>: new branch in its own worktree next to the repository
# (../<repo>-<branch>), and cd into it.
ga() {
local branch="${1:-}" top main dir
[[ -n $branch ]] || { echo "usage: ga <branch>"; return 1; }
top=$(git rev-parse --show-toplevel 2>/dev/null) || { echo "ga: not inside a git repository"; return 1; }
main=$(dirname "$(git -C "$top" rev-parse --path-format=absolute --git-common-dir)")
dir="$(dirname "$main")/$(basename "$main")-${branch//\//-}"
git -C "$top" worktree add -b "$branch" "$dir" && cd "$dir"
}
# gd: remove the current worktree and its branch (asks first; never the main one).
gd() {
local top main branch answer
top=$(git rev-parse --show-toplevel 2>/dev/null) || { echo "gd: not inside a git repository"; return 1; }
main=$(git worktree list --porcelain | awk '/^worktree / { print $2; exit }')
[[ $top != "$main" ]] || { echo "gd: this is the main worktree; not removing it"; return 1; }
branch=$(git branch --show-current)
read -rp "Remove worktree $top and branch $branch? [y/N] " answer
[[ $answer == [yY]* ]] || return 1
cd "$main" && git worktree remove "$top" && git branch -D "$branch"
}

View file

@ -0,0 +1,34 @@
# Sakura Line - rsync watchers.
# rsw <source> <destination>: keep destination in sync with source in the
# background, re-syncing on every change. The destination can be remote
# (host:path); one SSH connection is reused, so you authenticate once.
rsw() {
(( $# == 2 )) || { echo "usage: rsw <source> <destination>"; return 1; }
local src="${1%/}" dest="$2" sockets="${XDG_RUNTIME_DIR:-$HOME/.ssh}"
local rsh="ssh -o ControlMaster=auto -o ControlPath=$sockets/rsw-%r@%h:%p -o ControlPersist=yes"
setsid --fork env RSYNC_RSH="$rsh" bash -c '
rsync -a "$1/" "$2"
while inotifywait -r -q -e modify,create,delete,move "$1" >/dev/null; do rsync -a "$1/" "$2"; done
' rsw-watch "$src" "$dest" >/dev/null 2>&1
echo "watching $src -> $dest"
}
# lsw: list watchers. dsw: stop them all.
lsw() {
local pid cmd rest found=0
while read -r pid cmd; do
rest="${cmd##*rsw-watch }"
echo "$pid: ${rest% *} -> ${rest##* }"
found=1
done < <(pgrep -af 'rsw-watch ')
(( found )) || echo "no active watchers"
}
dsw() {
local pid found=0
for pid in $(pgrep -f 'rsw-watch '); do
kill -- -"$pid" 2>/dev/null && echo "stopped $pid" && found=1
done
(( found )) || echo "no active watchers"
}

View file

@ -0,0 +1,82 @@
# Sakura Line - ssh helpers.
# ssh: when an interactive session drops, tidy the terminal and reconnect until
# you press Ctrl-C. Only a real dropped shell reconnects: a remote command,
# piped input, or a failure within the first 30 seconds (bad host, bad key)
# returns normally, so nothing is ever replayed by accident.
ssh() {
local rc started=$SECONDS
command ssh "$@"
rc=$?
[[ -t 1 ]] || return $rc
_ssh_disarm
if (( rc != 255 )) || [[ ! -t 0 ]] || ! _ssh_interactive "$@" || (( SECONDS - started < 30 )); then
return $rc
fi
# A subshell, so Ctrl-C stops both the attempt and the loop.
(
while :; do
echo "Connection lost. Reconnecting (Ctrl-C to stop)..."
sleep 2
command ssh "$@"
rc=$?
_ssh_disarm
(( rc != 255 )) && exit $rc
done
)
}
# A connection that dies mid-session leaves the remote tmux or editor's
# terminal modes on (mouse reporting floods the prompt); switch them off.
_ssh_disarm() {
printf '\e[?1000l\e[?1002l\e[?1003l\e[?1006l\e[?1004l\e[?1049l\e[?25h'
}
# True when the arguments open a shell: a destination and no remote command,
# counting a RemoteCommand set in ssh_config.
_ssh_interactive() {
local value_opts="BbcDEeFIiJLlmOoPpQRSWw" argv=("$@") arg letters i dest="" opts_done=""
while (( $# )); do
arg="$1"; shift
if [[ -z $opts_done && $arg == "--" ]]; then
opts_done=1
elif [[ -z $opts_done && $arg == -?* ]]; then
letters="${arg#-}"
for (( i = 0; i < ${#letters}; i++ )); do
if [[ $value_opts == *"${letters:i:1}"* ]]; then
(( i == ${#letters} - 1 )) && shift
break
fi
done
elif [[ -z $dest ]]; then
dest="$arg"
else
return 1
fi
done
[[ -n $dest ]] || return 1
local resolved
resolved=$(command ssh -G "${argv[@]}" 2>/dev/null) || return 1
! grep -i '^remotecommand ' <<<"$resolved" | grep -qvi '^remotecommand none$'
}
# fip <host> <port>...: forward remote ports to localhost (web dev against a remote box).
fip() {
(( $# >= 2 )) || { echo "usage: fip <host> <port>..."; return 1; }
local host="$1" port; shift
for port in "$@"; do
command ssh -f -N -L "$port:localhost:$port" "$host" && echo "localhost:$port -> $host:$port"
done
}
# dip <port>...: stop those forwards. lip: list active forwards.
dip() {
(( $# >= 1 )) || { echo "usage: dip <port>..."; return 1; }
local port
for port in "$@"; do
pkill -f "ssh.*-L $port:localhost:$port" && echo "stopped $port" || echo "no forward on $port"
done
}
lip() { pgrep -af 'ssh.*-L [0-9]+:localhost:[0-9]+' || echo "no active forwards"; }