From 87ec517a51f0e2abb1fe7771ec805fe642fb4839 Mon Sep 17 00:00:00 2001 From: Jim Shepich III Date: Thu, 15 Oct 2026 00:36:13 -0400 Subject: [PATCH] Working on aliases --- babygram/Xmodmap | 9 ++++++ bash_aliases | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ tmux.conf | 5 ++-- vimrc | 7 +++++ 4 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 babygram/Xmodmap create mode 100755 bash_aliases diff --git a/babygram/Xmodmap b/babygram/Xmodmap new file mode 100644 index 0000000..c4787f3 --- /dev/null +++ b/babygram/Xmodmap @@ -0,0 +1,9 @@ +!keycode 97 = Control_R NoSymbol Control_R +!add control = Control_R + +! Map right control to Home for tmux. +keycode 97 = F1 + +keycode 64 = Alt_L Meta_L Alt_L Meta_L +keycode 108 = Alt_R Meta_R Alt_R Meta_R + diff --git a/bash_aliases b/bash_aliases new file mode 100755 index 0000000..5640201 --- /dev/null +++ b/bash_aliases @@ -0,0 +1,75 @@ +# Filesystem navigation. +alias l="ls -lhF --color=always" +alias ll="ls -AlhF --color=always" +alias lz="ls -AlhFZ --color=always" + +mcd() { + mkdir -p "$1" && cd "$1" +} +cdl() { + cd "$1" && ls -lhF --color=always +} +cdll() { + cd "$1" && ls -AlhF --color=always +} + + +# Aliases for Python venv management. +alias activate="source .venv/bin/activate" +alias mkvenv="python3 -m venv .venv" + +# Aliases for common podman/podman compose tasks. +alias pcup="podman-compose up" +alias pcupd="podman-compose up -d" +alias pcdown="podman-compose down" +alias pps="podman ps" +alias ccedit="nano container-compose.yaml" + +# Enable/disable NGINX sites defined in /etc/nginx/sites-available +# by symlinking it to (or unlinking it from) /etc/nginx/sites-enabled. +nginx-enable(){ + sudo ln -s "/etc/nginx/sites-available/$1.conf" "/etc/nginx/sites-enabled/$1.conf" +} +nginx-disable(){ + sudo rm "/etc/nginx/sites-enabled/$1.conf" +} + +# In a subdirectory of /srv/{USER}, run a command as USER. +alias srvdo='sudo -u $(pwd | cut -d "/" -f3) ' + +create-service-user(){ + # Accepts input in service_name:uid format. Assumes gid=uid. + service=$(echo $1 | cut -d ':' -f1) + uid=$(echo $1 | cut -d ':' -f2) + echo "Creating service user $service ($uid)" + + # Create group if not exists. + echo Running groupadd... + getent group $service || sudo groupadd --system --gid "$uid" "$service" + + # Create user if not exists. + echo Running useradd... + getent passwd $service || sudo useradd --system --uid "$uid" --gid "$uid" \ + --home-dir /var/lib/$service \ + --create-home \ + --shell /sbin/nologin \ + "$service" + + # Create a directory in /srv for the service. + echo Creating directory in /srv ... + sudo mkdir -p /srv/$service + sudo chown -R $service:$service /srv/$service + sudo chmod -R 770 /srv/$service + + # loginctl enable-linger "$service" + + # Add entries in /etc/sub*id; assumes these files are sorted. + echo Setting up subids... + last_subid_start=$(tail -1 /etc/subuid | cut -d ':' -f2) + last_subid_range=$(tail -1 /etc/subuid | cut -d ':' -f3) + let "next_subid = $last_subid_start + $last_subid_range" + cat /etc/subuid | grep $service || echo "$service:$next_subid:65536" | sudo tee -a /etc/subuid + cat /etc/subgid | grep $service || echo "$service:$next_subid:65536" | sudo tee -a /etc/subgid + + echo Done! +} diff --git a/tmux.conf b/tmux.conf index 11d07e8..d3b164a 100644 --- a/tmux.conf +++ b/tmux.conf @@ -1,5 +1,6 @@ # Use Home (mapped to Menu key on Babygram) as the primary prefix. -set -g prefix Home +set -g prefix F1 +bind-key F1 send-prefix # Keep Ctrl+B available as an alternative. set -g prefix2 C-b @@ -10,4 +11,4 @@ set -g prefix2 C-b # Reload config. -bind M-r source-file ~/.tmux.conf +bind r source-file ~/.tmux.conf diff --git a/vimrc b/vimrc index efacc7b..750ba58 100644 --- a/vimrc +++ b/vimrc @@ -32,6 +32,9 @@ filetype plugin indent on " Make tabs as wide as two spaces set tabstop=2 shiftwidth=0 softtabstop=2 noexpandtab +" Use two spaces instead of tabs in yaml files. +autocmd FileType yaml,yml setlocal ts=2 sts=2 sw=2 expandtab + " Copy indentation from previous line set autoindent nosmartindent nocindent indentexpr= @@ -54,3 +57,7 @@ endif " :W sudo saves the file (useful for handling the permission-denied error) command! W execute 'w !sudo tee % > /dev/null' edit! + +" Likewise :S saves the file as the service user when in subdirs of +" /srv/$SERVICE_USER +command! S execute "w !sudo -u $(pwd | cut -d '/' -f3) tee % > /dev/null" edit!