Compare commits

..

No commits in common. "445467b1b5b0d6557aadf52fc0fed02dbbac02b0" and "4ffe0063e76325e434bbc8135e0d96c716a9159f" have entirely different histories.

10 changed files with 167 additions and 283 deletions

View file

@ -1,96 +1,55 @@
# Read Write eXecute
One project to rule them all.
A tiny framework to read, write & execute things.
---
## Table Of Contents {#toc}
* 1 [Why](#why)
* 2 [How](#how)
* 2.1 [Shell](#how-shell)
* 2.2 [Python](#how-python)
* 3 [What](#what)
* 3.1 [Features](#what-features)
* 3.2 [Environment variables](#what-variables)
* 4 [Who](#who)
* 5 [Where](#where)
* 5.1 [Chat](#where-chat)
* 5.2 [Repo](#where-repo)
* 5.3 [Site](#where-site)
* 6 [When](#when)
* 6.1 [Release tasks](#when-release)
* 6.2 [Further tasks](#when-further)
## Why
---
## 1 [Why](#toc) {#why}
## How
---
## 2 [How](#toc) {#how}
Two interpreted languages for flexibility.
### 2.1 [Shell](#how) {#how-shell}
* [X] functions to
* [X] alias
* [X] lint
* [X] Git
* [X] Python
* [X] Shell
* [X] log
* [X] rescue
* [X] Hetzner
* [X] OVH
* [X] profiles
* [X] ffmpeg
* [X] tmux
### 2.2 [Python](#how) {#how-python}
## What
---
## 3 [What](#toc) {#what}
## Who
### 3.1 [Features](#what) {#what-features}
### By
* [ ] self
* [ ] install modules
* [Marc Beninca](https://marc.beninca.link)
### 3.2 [Environment variables](#what) {#what-variables}
### For
* myself
---
## 4 [Who](#toc) {#who}
## Where
* Author: [Marc Beninca](https://forge.rwx.work/marc.beninca)
---
## 5 [Where](#toc) {#where}
### 5.1 [Chat](#where) {#where-chat}
### Chat
* [Discord](https://discord.com/channels/983145051985154108/1255894474895134761)
* [IRC](ircs://irc.libera.chat/##rwx)
### 5.2 [Repo](#where) {#where-repo}
### Forge
* [Code](https://forge.rwx.work/rwx.work/rwx)
* [Feed](https://forge.rwx.work/rwx.work/rwx.rss)
* [Actions](https://forge.rwx.work/rwx.work/rwx/actions)
* [Repository](https://forge.rwx.work/rwx.work/rwx)
* [RSS](https://forge.rwx.work/rwx.work/rwx.rss)
* [Workflows](https://forge.rwx.work/rwx.work/rwx/actions)
### 5.3 [Site](#where) {#where-site}
### Deployment
* [Web](https://rwx.rwx.work)
* [Site](https://rwx.rwx.work)
---
## 6 [When](#toc) {#when}
## When
### 6.1 [Release tasks](#when) {#when-release}
### Task stack
#### Python
@ -113,5 +72,3 @@ Two interpreted languages for flexibility.
* apt
* apt-file search | grep
* ffmpeg
### 6.2 [Further tasks](#when) {#when-further}

View file

@ -1,8 +1,10 @@
RWX_GIT_LOG_FORMAT="\
%C(auto)%h%d
S %C(red)%GS
A %C(green)%ai %an %ae
C %C(blue)%ci %cn %ce
A %C(green)%an %ae
%C(green)%ai
C %C(blue)%cn %ce
%C(blue)%ci
%B"
# add to index

View file

@ -1,26 +0,0 @@
# ╭──────╮
# │ file │
# ╰──────╯
rwx_file_append() {
local file="${1}"
local text="${2}"
if [ -n "${file}" ]; then
printf "%s" "${text}" >>"${file}"
fi
}
rwx_file_empty() {
local file="${1}"
if [ -n "${file}" ]; then
rwx_file_write "${file}" ""
fi
}
rwx_file_write() {
local file="${1}"
local text="${2}"
if [ -n "${file}" ]; then
printf "%s" "${text}" >"${file}"
fi
}

View file

@ -1,7 +1,3 @@
# ╭────╮
# │ fs │
# ╰────╯
rwx_fs_make_btrfs() {
local device="${1}"
local label="${2}"

View file

@ -23,18 +23,12 @@ rwx_gnome_background_win3() {
# ╰───────┴───────╯
rwx_gnome_proxy() {
local port="${1}"
local prefix="org.gnome.system.proxy"
case "${port}" in
"")
gsettings set "${prefix}" "mode" "none"
;;
*)
gsettings set "${prefix}" "mode" "manual"
gsettings set "${prefix}.socks" "host" "localhost"
gsettings set "${prefix}.socks" "port" "${port}"
;;
local value
case "${1}" in
"on") value="manual" ;;
*) value="none" ;;
esac
gsettings set "org.gnome.system.proxy" "mode" "${value}"
}
# ╭───────┬─────╮

View file

@ -1,11 +1,3 @@
# ╭─────╮
# │ log │
# ╰─────╯
# ╭─────┬───────────╮
# │ log │ constants │
# ╰─────┴───────────╯
RWX_LOG_LEVEL_FATAL=0
RWX_LOG_LEVEL_ERROR=1
RWX_LOG_LEVEL_WARN=2
@ -13,16 +5,8 @@ RWX_LOG_LEVEL_INFO=3
RWX_LOG_LEVEL_DEBUG=4
RWX_LOG_LEVEL_TRACE=5
# ╭─────┬───────────╮
# │ log │ variables │
# ╰─────┴───────────╯
RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO}
# ╭─────┬─────╮
# │ log │ log │
# ╰─────┴─────╯
rwx_log() { rwx_log_info "${@}"; }
rwx_log_debug() {

View file

@ -1,9 +1,5 @@
#! /usr/bin/env sh
# ╭──────╮
# │ main │
# ╰──────╯
# ╭──────┬───────────╮
# │ main │ constants │
# ╰──────┴───────────╯
@ -31,50 +27,16 @@ RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
# ╭──────┬──────
# │ main │ main
# ╰──────┴──────
# ╭──────┬──────
# │ main │ shell
# ╰──────┴──────
# run initial steps
rwx_main() {
# source system root
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
return 1
fi
# source user root
rwx_source "${RWX_SELF_USER}"
# context / command
if [ -n "${RWX_COMMAND_NAME}" ]; then
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
# context / shell
else
rwx_self_init
fi
}
# ╭──────┬────────╮
# │ main │ source │
# ╰──────┴────────╯
# source code from file path
rwx_source() {
local path="${1}"
[ -d "${path}" ] ||
return 1
local count module
count=0
__rwx_log "" \
". ${path}"
rwx_ifs_set
for module in $(rwx_find_shell "${path}" "${RWX_MAIN_NAME}"); do
count=$((count + 1))
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
module="${path}/${module}"
# shellcheck disable=SC1090
. "${module}"
done
rwx_ifs_unset
# test if active shell is in interactive mode
rwx_shell_interactive() {
case "${-}" in
*i*) ;;
*) return 1 ;;
esac
}
# ╭──────┬─────╮
@ -91,35 +53,6 @@ __rwx_log() {
fi
}
# ╭──────┬───────╮
# │ main │ shell │
# ╰──────┴───────╯
# test if active shell is in interactive mode
rwx_shell_interactive() {
case "${-}" in
*i*) ;;
*) return 1 ;;
esac
}
# ╭──────┬─────╮
# │ main │ ifs │
# ╰──────┴─────╯
# set internal field separator to line feed
rwx_ifs_set() {
_RWX_IFS="${IFS}"
IFS="
"
}
# unset internal field separator
rwx_ifs_unset() {
IFS="${_RWX_IFS}"
unset RWX_IFS
}
# ╭──────┬──────╮
# │ main │ find │
# ╰──────┴──────╯
@ -148,8 +81,64 @@ rwx_find_shell() {
}
# ╭──────┬─────╮
# │ main │ run
# │ main │ ifs
# ╰──────┴─────╯
rwx_ifs_set() {
_RWX_IFS="${IFS}"
IFS="
"
}
rwx_ifs_unset() {
IFS="${_RWX_IFS}"
unset RWX_IFS
}
# ╭──────┬────────╮
# │ main │ source │
# ╰──────┴────────╯
rwx_source() {
local path="${1}"
[ -d "${path}" ] ||
return 1
local count module
count=0
__rwx_log "" \
". ${path}"
rwx_ifs_set
for module in $(rwx_find_shell "${path}" "${RWX_MAIN_NAME}"); do
count=$((count + 1))
__rwx_log "$(printf "%02d" "${count}") ${module%.sh}"
module="${path}/${module}"
# shellcheck disable=SC1090
. "${module}"
done
rwx_ifs_unset
}
# ╭──────╮
# │ main │
# ╰──────╯
# run initial steps
rwx_main() {
# system root
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}"
return 1
fi
# user root
rwx_source "${RWX_SELF_USER}"
# context / command
if [ -n "${RWX_COMMAND_NAME}" ]; then
"${RWX_SELF_COMMAND}${RWX_COMMAND_NAME}" "${@}"
# context / shell
else
rwx_self_init
fi
}
# run main function
rwx_main "${@}"

View file

@ -92,7 +92,7 @@ rwx_self_init() {
_rwx_cmd_rwx_install() { rwx_self_install "${@}"; }
rwx_self_install() {
local target="${1}"
local command file name root
local command file root
# code
if [ -n "${target}" ]; then
root="${target}${RWX_ROOT_SYSTEM}"
@ -101,14 +101,10 @@ rwx_self_install() {
fi
# commands
root="${target}/usr/local/bin"
name="${RWX_SELF_NAME}.sh"
file="${root}/${name}"
rwx_remove "${file}"
rwx_link "${file}" "${RWX_MAIN_PATH}"
for command in $(rwx_self_commands); do
file="${root}/${command}"
rwx_remove "${file}"
rwx_link "${file}" "${name}"
rwx_link "${file}" "${RWX_MAIN_PATH}"
done
# sh
file="${target}/etc/profile.d/${RWX_SELF_NAME}.sh"

View file

@ -1,7 +1,3 @@
# ╭──────╮
# │ tmux │
# ╰──────╯
# ╭──────┬───────╮
# │ tmux │ setup │
# ╰──────┴───────╯
@ -51,8 +47,6 @@ set-option -g set-titles on
# set title to working directory
set-option -g set-titles-string '\
#(basename \"\${TMUX}\" | cut --delimiter \",\" --fields \"1\")\
- \
#{session_name}\
- \
#{window_index}∕#{session_windows} #{window_name}\
@ -82,10 +76,10 @@ set-option -g pane-border-style fg=blue
# ╰────────┴────────╯
# status lines
set-option -g status 2
set-option -g status 3
# background color
set-option -g status-bg '#080808'
set-option -g status-bg '#0D0D0D'
# foreground color
set-option -g status-fg white
@ -93,99 +87,83 @@ set-option -g status-fg white
# line 1
set-option -g status-format[0] '\
#{W:\
#[bg=##202020] #[bg=##303030]\
#{?window_zoomed_flag,#[fg=magenta][, }\
#[fg=yellow]#{window_index}\
#{?window_zoomed_flag,#[fg=magenta]], }\
\
#{?window_active,#[fg=green],\
#{?window_activity_flag,#[fg=red],#[fg=yellow]}}\
#[bg=##181818]#{?window_zoomed_flag,#[fg=magenta][, }\
#[bg=##282828]#{window_name}\
#[bg=##181818]#{?window_zoomed_flag,#[fg=magenta]], }\
#[fg=default]\
#{?window_activity_flag,#[fg=red],#[fg=blue]}}\
#{window_name}\
#[bg=##303030] #[bg=##202020] \
#[bg=default] \
}\
#[align=right]\
#[fg=yellow]\
#[bg=##181818] \
#[bg=##282828]%H:%M:%S\
#[bg=##181818]#{?client_prefix,#[fg=green]p, }\
#[bg=##202020] #[bg=##303030] \
#[fg=yellow]%H:%M:%S\
#[bg=##303030] #[bg=##202020]\
#{?client_prefix,#[fg=green]p, }\
'
# line 2
set-option -g status-format[1] '\
#{S:\
#{?session_many_attached,#[fg=magenta],\
#{?session_attached,#[fg=red],#[fg=yellow]}}\
#[bg=##181818] \
#[bg=##282828]#{session_name}\
#[bg=##181818] \
#[fg=default]\
#[bg=##202020] #[bg=##303030] \
#{?session_many_attached,#[fg=red],\
#{?session_attached,#[fg=magenta],#[fg=blue]}}\
#{session_name}\
#[bg=##303030] #[bg=##202020] \
#[bg=default] \
}\
#[fg=yellow]→\
#[fg=default] \
#[fg=green]\
#[bg=##181818] \
#[bg=##282828]#{session_name}\
#[bg=##181818] \
#[fg=yellow]→ #[fg=green]#{session_name} \
#[align=right]\
#[fg=yellow]\
#[bg=##181818] \
#[bg=##282828]%Y-%m-%d\
#[bg=##181818] \
#[bg=##202020] #[bg=##303030] \
#[fg=yellow]%Y-%m-%d\
#[bg=##303030] #[bg=##202020] \
'
# line 3
set-option -g status-format[2] '\
#[fg=yellow]\
#(lsof -U \
| awk \"/^tmux:.*\\(LISTEN\\)$/ {print \\\$9}\" \
| xargs -n \"1\" basename \
| sed \"s/^/#[fg=yellow]#[bg=##181818] #[bg=##282828]/\
;s/\$/#[bg=##181818] #[fg=default]#[bg=default] /\" \
| xargs echo \
)\
#[fg=default] \
#[fg=yellow]→\
#[fg=default] \
#[fg=green]\
#[bg=##181818] \
#[bg=##282828]#(basename \"\${TMUX}\" \
| cut --delimiter \",\" --fields \"1\")\
#[bg=##181818] \
#[fg=cyan]#{pane_current_path}\
#[align=right]\
#[fg=yellow]\
#[bg=##181818] \
#[bg=##282828]#{host}\
#[bg=##181818] \
#[bg=##202020] #[bg=##303030] \
#[fg=yellow]#{host}\
#[bg=##303030] #[bg=##202020] \
'
# line 4
set-option -g status-format[3] '\
#{P:\
#[bg=##181818] #[bg=##282828]\
#{?pane_active,#[fg=green],#[fg=yellow]}\
#[bg=##202020] #[bg=##303030] \
#[fg=yellow]#{pane_index}\
\
#{?pane_active,#[fg=green],#[fg=blue]}\
#{pane_current_command}\
#[bg=##181818] \
#[bg=##303030] #[bg=##202020] \
#[bg=default] \
}\
#[align=right]\
#[bg=##181818] #[bg=##282828]\
#[bg=##202020] #[bg=##303030] \
#{?uid,#[fg=green],#[fg=red]}\
#{user}\
#[bg=##181818] \
#[bg=##303030] #[bg=##202020] \
'
# line 5
set-option -g status-format[4] '\
#{P:\
#[bg=##181818] #[bg=##282828]\
#{?pane_active,#[fg=green],#[fg=yellow]}\
#[bg=##202020] #[bg=##303030] \
#[fg=yellow]#{pane_index}\
\
#{?pane_active,#[fg=green],#[fg=blue]}\
#{pane_width}×#{pane_height}\
#[bg=##181818] \
#[bg=##303030] #[bg=##202020] \
#[bg=default] \
}\
#[align=right]\
#[bg=##181818] #[bg=##282828]\
#[bg=##202020] #[bg=##303030] \
#[fg=green]#{window_width}×#{window_height}\
#[bg=##181818] \
#[bg=##303030] #[bg=##202020] \
'
# refresh period
@ -201,9 +179,8 @@ set-option -g status-position bottom
# detach client
bind-key -n F6 detach-client
# new
bind-key -n S-M-Down new-session
bind-key -n S-M-Right new-window
# new window
bind-key -n F2 new-window
# select pane
bind-key -n C-S-Down select-pane -D
@ -212,7 +189,7 @@ bind-key -n C-S-Right select-pane -R
bind-key -n C-S-Up select-pane -U
# status lines
bind-key -n C-F6 set-option -g status off
bind-key -n C-F10 set-option -g status off
bind-key -n C-F1 set-option -g status on
bind-key -n C-F2 set-option -g status 2
bind-key -n C-F3 set-option -g status 3
@ -239,15 +216,12 @@ bind-key C-w command-prompt { rename-window '%%' }
bind-key h split-window -h
bind-key v split-window -v
# kill server
bind-key k kill-server
# toggle mouse
bind-key t set-option -g mouse \\; display-message 'mouse = #{mouse}'
# reload configuration
bind-key r source-file ${file} \\; display-message 'source-file ${file}'
# toggle mouse
bind-key t set-option -g mouse \\; display-message 'mouse = #{mouse}'
# swap window
bind-key M-Left swap-window -t -1
bind-key M-Right swap-window -t +1
@ -259,8 +233,7 @@ bind-key M-Right swap-window -t +1
# ╭───────────────────┼───────────┼─────────┼─────┼───────┤
# │ command-prompt │ │ │ │ : │
# │ copy-mode │ │ │ │ PPage │
# │ detach-client │ F6 │ │ │ d │
# │ kill-server │ │ k │ │ │
# │ detach-client │ │ │ │ d │
# │ new-session │ │ │ │ │
# │ new-window │ F2 │ │ │ c │
# │ next-window │ M-Right │ │ │ n │
@ -273,7 +246,7 @@ bind-key M-Right swap-window -t +1
# │ select-pane -R │ C-S-Right │ │ │ │
# │ select-pane -U │ C-S-Up │ │ │ │
# │ set -g mouse │ │ t │ │ │
# │ set -g status off │ C-F6 │ │ │ │
# │ set -g status off │ C-F10 │ │ │ │
# │ set -g status on │ C-F1 │ │ │ │
# │ set -g status 2 │ C-F2 │ │ │ │
# │ set -g status 3 │ C-F3 │ │ │ │

View file

@ -1,6 +1,25 @@
# ╭──────╮
# │ util │
# ╰──────╯
rwx_file_append() {
local file="${1}"
local text="${2}"
if [ -n "${file}" ]; then
printf "%s" "${text}" >>"${file}"
fi
}
rwx_file_empty() {
local file="${1}"
if [ -n "${file}" ]; then
rwx_file_write "${file}" ""
fi
}
rwx_file_write() {
local file="${1}"
local text="${2}"
if [ -n "${file}" ]; then
printf "%s" "${text}" >"${file}"
fi
}
rwx_link() {
local link="${1}"