Working on aliases

This commit is contained in:
Jim Shepich III 2026-10-15 00:36:13 -04:00
parent c544e55eba
commit 87ec517a51
4 changed files with 94 additions and 2 deletions

9
babygram/Xmodmap Normal file
View File

@ -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

75
bash_aliases Executable file
View File

@ -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!
}

View File

@ -1,5 +1,6 @@
# Use Home (mapped to Menu key on Babygram) as the primary prefix. # 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. # Keep Ctrl+B available as an alternative.
set -g prefix2 C-b set -g prefix2 C-b
@ -10,4 +11,4 @@ set -g prefix2 C-b
# Reload config. # Reload config.
bind M-r source-file ~/.tmux.conf bind r source-file ~/.tmux.conf

7
vimrc
View File

@ -32,6 +32,9 @@ filetype plugin indent on
" Make tabs as wide as two spaces " Make tabs as wide as two spaces
set tabstop=2 shiftwidth=0 softtabstop=2 noexpandtab 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 " Copy indentation from previous line
set autoindent nosmartindent nocindent indentexpr= set autoindent nosmartindent nocindent indentexpr=
@ -54,3 +57,7 @@ endif
" :W sudo saves the file (useful for handling the permission-denied error) " :W sudo saves the file (useful for handling the permission-denied error)
command! W execute 'w !sudo tee % > /dev/null' <bar> edit! command! W execute 'w !sudo tee % > /dev/null' <bar> 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" <bar> edit!