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 # Read Write eXecute
One project to rule them all. A tiny framework to read, write & execute things.
--- ---
## Table Of Contents {#toc} ## Why
* 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)
--- ---
## 1 [Why](#toc) {#why} ## How
--- ---
## 2 [How](#toc) {#how} ## What
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}
--- ---
## 3 [What](#toc) {#what} ## Who
### 3.1 [Features](#what) {#what-features} ### By
* [ ] self * [Marc Beninca](https://marc.beninca.link)
* [ ] install modules
### 3.2 [Environment variables](#what) {#what-variables} ### For
* myself
--- ---
## 4 [Who](#toc) {#who} ## Where
* Author: [Marc Beninca](https://forge.rwx.work/marc.beninca) ### Chat
---
## 5 [Where](#toc) {#where}
### 5.1 [Chat](#where) {#where-chat}
* [Discord](https://discord.com/channels/983145051985154108/1255894474895134761) * [Discord](https://discord.com/channels/983145051985154108/1255894474895134761)
* [IRC](ircs://irc.libera.chat/##rwx) * [IRC](ircs://irc.libera.chat/##rwx)
### 5.2 [Repo](#where) {#where-repo} ### Forge
* [Code](https://forge.rwx.work/rwx.work/rwx) * [Repository](https://forge.rwx.work/rwx.work/rwx)
* [Feed](https://forge.rwx.work/rwx.work/rwx.rss) * [RSS](https://forge.rwx.work/rwx.work/rwx.rss)
* [Actions](https://forge.rwx.work/rwx.work/rwx/actions) * [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 #### Python
@ -113,5 +72,3 @@ Two interpreted languages for flexibility.
* apt * apt
* apt-file search | grep * apt-file search | grep
* ffmpeg * ffmpeg
### 6.2 [Further tasks](#when) {#when-further}

View file

@ -1,8 +1,10 @@
RWX_GIT_LOG_FORMAT="\ RWX_GIT_LOG_FORMAT="\
%C(auto)%h%d %C(auto)%h%d
S %C(red)%GS S %C(red)%GS
A %C(green)%ai %an %ae A %C(green)%an %ae
C %C(blue)%ci %cn %ce %C(green)%ai
C %C(blue)%cn %ce
%C(blue)%ci
%B" %B"
# add to index # 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() { rwx_fs_make_btrfs() {
local device="${1}" local device="${1}"
local label="${2}" local label="${2}"

View file

@ -23,18 +23,12 @@ rwx_gnome_background_win3() {
# ╰───────┴───────╯ # ╰───────┴───────╯
rwx_gnome_proxy() { rwx_gnome_proxy() {
local port="${1}" local value
local prefix="org.gnome.system.proxy" case "${1}" in
case "${port}" in "on") value="manual" ;;
"") *) value="none" ;;
gsettings set "${prefix}" "mode" "none"
;;
*)
gsettings set "${prefix}" "mode" "manual"
gsettings set "${prefix}.socks" "host" "localhost"
gsettings set "${prefix}.socks" "port" "${port}"
;;
esac 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_FATAL=0
RWX_LOG_LEVEL_ERROR=1 RWX_LOG_LEVEL_ERROR=1
RWX_LOG_LEVEL_WARN=2 RWX_LOG_LEVEL_WARN=2
@ -13,16 +5,8 @@ RWX_LOG_LEVEL_INFO=3
RWX_LOG_LEVEL_DEBUG=4 RWX_LOG_LEVEL_DEBUG=4
RWX_LOG_LEVEL_TRACE=5 RWX_LOG_LEVEL_TRACE=5
# ╭─────┬───────────╮
# │ log │ variables │
# ╰─────┴───────────╯
RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO} RWX_LOG_LEVEL=${RWX_LOG_LEVEL_INFO}
# ╭─────┬─────╮
# │ log │ log │
# ╰─────┴─────╯
rwx_log() { rwx_log_info "${@}"; } rwx_log() { rwx_log_info "${@}"; }
rwx_log_debug() { rwx_log_debug() {

View file

@ -1,9 +1,5 @@
#! /usr/bin/env sh #! /usr/bin/env sh
# ╭──────╮
# │ main │
# ╰──────╯
# ╭──────┬───────────╮ # ╭──────┬───────────╮
# │ main │ constants │ # │ main │ constants │
# ╰──────┴───────────╯ # ╰──────┴───────────╯
@ -31,50 +27,16 @@ RWX_SELF_USER="${HOME}/${RWX_SELF_NAME}"
RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}" RWX_MAIN_PATH="${RWX_ROOT_SYSTEM}/${RWX_MAIN_NAME}"
# ╭──────┬────── # ╭──────┬──────
# │ main │ main # │ main │ shell
# ╰──────┴────── # ╰──────┴──────
# run initial steps # test if active shell is in interactive mode
rwx_main() { rwx_shell_interactive() {
# source system root case "${-}" in
if ! rwx_source "${RWX_ROOT_SYSTEM}"; then *i*) ;;
__rwx_log "Not a directory: ${RWX_ROOT_SYSTEM}" *) return 1 ;;
return 1 esac
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
} }
# ╭──────┬─────╮ # ╭──────┬─────╮
@ -91,35 +53,6 @@ __rwx_log() {
fi 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 │ # │ 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 # run main function
rwx_main "${@}" rwx_main "${@}"

View file

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

View file

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

View file

@ -1,6 +1,25 @@
# ╭──────╮ rwx_file_append() {
# │ util │ 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() { rwx_link() {
local link="${1}" local link="${1}"