« get me outta code hell

dotfiles - Miscellaneous configuration files of my personal use
about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--.tmux.conf3
-rw-r--r--.zshrc22
-rw-r--r--apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap11
-rw-r--r--apps/Sublime Text 4/Packages/User/HSMusic Editing.py43
-rw-r--r--apps/Sublime Text 4/Packages/User/Preferences.sublime-settings1
-rw-r--r--apps/krita/krita-shortcuts.shortcuts26
-rwxr-xr-xdevice/acme_post4
-rwxr-xr-xdevice/acme_pre33
-rw-r--r--lib/plumbing8
-rwxr-xr-xscripts/acme/E8
-rwxr-xr-xscripts/acme/WT3
-rwxr-xr-xscripts/acme/WT+3
-rwxr-xr-xscripts/acme/Wikitag36
-rwxr-xr-xscripts/acme/acme-shell3
-rwxr-xr-xscripts/acme/wikebab24
-rwxr-xr-xscripts/acme/winn3
-rw-r--r--scripts/acme_dynamic/readme.txt2
-rw-r--r--userstuff/hsmusic/Switch HSMusic websites.user.js4
19 files changed, 232 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
index e43b0f9..f43b417 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,4 @@
 .DS_Store
+
+scripts/acme_dynamic/*
+!scripts/acme_dynamic/readme.txt
\ No newline at end of file
diff --git a/.tmux.conf b/.tmux.conf
index 04760e3..89a5d4b 100644
--- a/.tmux.conf
+++ b/.tmux.conf
@@ -8,6 +8,9 @@ set -sg escape-time 0
 set -g status-style bg=colour235,fg=colour249
 set-window-option -g window-status-current-style fg=colour251,bright
 
+set -g set-titles on
+set -g set-titles-string "#S: #W"
+
 bind '"' split-window -c "#{pane_current_path}"
 bind % split-window -h -c "#{pane_current_path}"
 bind c new-window -c "#{pane_current_path}"
diff --git a/.zshrc b/.zshrc
index e185d87..97d0ddf 100644
--- a/.zshrc
+++ b/.zshrc
@@ -8,6 +8,9 @@
 #   per-device configuration (post)    <dev-post>
 
 
+export DOTFILES="$(dirname "$(readlink -f "${(%):-%x}")")"
+
+
 # //// per-device configuration //////////////////////////////// <dev-pre> // #
 
 # Per-device configuration is kept here in dotfiles.git too, but it won't be
@@ -20,6 +23,7 @@
 
 device_preconfig() {
   source ~/.device_pre
+  [[ -v ACME ]] && source "$DOTFILES/device/acme_pre"
 }
 
 # The post-config file is intended to run commands that are so specialized to
@@ -28,6 +32,7 @@ device_preconfig() {
 
 device_postconfig() {
   source ~/.device_post
+  [[ -v ACME ]] && source "$DOTFILES/device/acme_post"
 }
 
 device_preconfig
@@ -42,12 +47,13 @@ export HISTSIZE=2000
 autoload -Uz select-word-style
 select-word-style bash
 
-if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+if [ -x /usr/bin/tput ] && [[ ${TERM} != "dumb" ]] && tput setaf 1 >&/dev/null; then
   autoload -U colors && colors
   PS1=$'\e[0;32;1m%n\e[0;32m@\e[32;1m%m \e[34m%1~ \e[0m%# '
   PROMPT="%F{green}%B%n%b@%B%m %F{blue}%1~%b%f %# "
 else
   PS1=$'%n@%m %1~ %# '
+  unset zle_bracketed_paste
 fi
 
 path+=("$HOME/bin")
@@ -91,6 +97,17 @@ if [[ -v DEVICE_HAS_NVM ]]; then
   [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
 fi
 
+# -- Plan 9 --
+
+if [[ -v DEVICE_HAS_PLAN9 ]]; then
+  export PLAN9="$DEVICE_PLAN9_INSTALLATION"
+  path+=("$PLAN9/bin")
+
+  plumber 2>/dev/null
+
+  alias acme='SHELL="'"$DOTFILES"'"/scripts/acme/acme-shell PATH="'"$DOTFILES"'/scripts/acme:$PATH" acme'
+fi
+
 # -- Python --
 
 if [[ -v DEVICE_HAS_PYTHON_3 ]]; then
@@ -118,6 +135,9 @@ export PATH
 # -- cli shenanigans --
 
 alias tm='tmux attach \; choose-tree -s && exit'
+alias grc='git rebase --continue'
+alias grs='git show $(cat .git/REBASE_HEAD)'
+alias gri='git rebase --interactive --autosquash'
 
 # -- file management utilities --
 
diff --git a/apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap b/apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap
index 3c842f5..4a5f8bb 100644
--- a/apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap
+++ b/apps/Sublime Text 4/Packages/User/Default (OSX).sublime-keymap
@@ -5,6 +5,12 @@
 	{ "keys": ["super+shift+d"], "command": "clone_file" },
 	{ "keys": ["ctrl+f"], "command": "distraction_free_window" },
 
+	{ "keys": ["super+r"], "command": "toggle_overwrite", "context":
+		[
+			{ "key": "selector", "operator": "equal", "operand": "text.plain" },
+		],
+	},
+
 	{ "keys": ["ctrl+enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line.sublime-macro"}, "context":
 		[
 			{ "key": "overlay_has_focus", "operator": "equal", "operand": false },
@@ -15,6 +21,11 @@
 	{ "keys": ["ctrl+shift+super+k"], "command": "prev_bookmark" },
 	{ "keys": ["super+k"], "command": "toggle_bookmark", "args": {"toggle_line": true } },
 
+	{ "keys": ["super+shift+l"], "command": "lower_case" },
+	{ "keys": ["super+shift+u"], "command": "upper_case" },
+
+	{ "keys": ["super+shift+e"], "command": "replace_all" },
+
 	// HSMusic wiki tag editing
 	// (bind caps lock to f16 in Karabiner-Elements)
 
diff --git a/apps/Sublime Text 4/Packages/User/HSMusic Editing.py b/apps/Sublime Text 4/Packages/User/HSMusic Editing.py
index a31cf06..9b8c369 100644
--- a/apps/Sublime Text 4/Packages/User/HSMusic Editing.py
+++ b/apps/Sublime Text 4/Packages/User/HSMusic Editing.py
@@ -189,7 +189,7 @@ def _normalize_region(region):
 def _match_tag_in_progress(view, region):
   region = _normalize_region(region)
   to_start = sublime.Region(view.line(region).a, region.a)
-  match = re.search('(\[\[(?:(?!]]|\|).)*)$', view.substr(to_start))
+  match = re.search(r'(\[\[(?:(?!]]|\|).)*)$', view.substr(to_start))
   if match:
     return match.group(1)
 
@@ -199,13 +199,13 @@ def _match_regex_ahead_same_line(view, region, regex):
   return re.search(regex, view.substr(to_end))
 
 def _match_rest_of_tag_in_progress(view, region):
-  regex = '^((?:(?!\[\[).)*]])'
+  regex = r'^((?:(?!\[\[).)*]])'
   match = _match_regex_ahead_same_line(view, region, regex)
   if match:
     return match.group(1)
 
 def _match_through_closing_html_tag(view, region, tag):
-  regex = f'^(.*?</{tag}>)'
+  regex = rf'^(.*?</{tag}>)'
   match = _match_regex_ahead_same_line(view, region, regex)
   if match:
     return match.group(1)
@@ -218,7 +218,7 @@ def _consider_reference_cycle(view, region, cycle):
 
   rest_of_tag = _match_rest_of_tag_in_progress(view, region)
 
-  rest_of_ref = re.search('^((?:(?!\|).)*:)', rest_of_tag)
+  rest_of_ref = re.search(r'^((?:(?!\|).)*:)', rest_of_tag)
   if rest_of_ref:
     return ('move', len(rest_of_ref.group(1)))
 
@@ -244,6 +244,35 @@ def _consider_reference_cycle(view, region, cycle):
   else:
     return ('insert', 'right', next_ref + ':', 0)
 
+def _consider_transform_url(view, region):
+  region = _normalize_region(region)
+  selected_text = view.substr(region)
+
+  start_through_selection = sublime.Region(view.line(region).a, region.b)
+  match = re.search(r'https?://\S+$', view.substr(start_through_selection))
+
+  if not match:
+    return None
+
+  # We don't have a convenient way to just replace a selection in one move,
+  # so just move to the end of the selection and try again next time...
+  if selected_text:
+    return ('collapse_move', len(selected_text))
+
+  url = match.group(0)
+  link = None
+
+  hsm = r'(?:https://(?:preview\.|staging\.)?hsmusic\.wiki/|http://localhost:\d+/)'
+
+  match = re.search(hsm + r'(album|track|artist|group|tag|flash)/(.+?)/', url)
+  if match:
+    link = f'[[{match.group(1)}:{match.group(2)}]]'
+
+  if not link:
+    return None
+
+  return ('replace_left', len(url), link, 0, 'right')
+
 def _guess_directory(name):
   directory = name
   directory =                     "-".join(directory.split(" "))
@@ -276,11 +305,15 @@ class ExitWikiTagCommand(_CursorAdaptiveCommand):
     if rest_of_tag:
       return ('collapse_move', len(rest_of_tag))
 
+    transform_url_action = _consider_transform_url(self.view, region)
+    if transform_url_action:
+      return transform_url_action
+
     region = _normalize_region(region)
     to_start = sublime.Region(self.view.line(region).a, region.a)
     to_end = sublime.Region(region.a, self.view.line(region).b)
     if to_start.a != to_start.b and to_end.a != to_end.b:
-      match = re.search('.*?([).,:;!?][).,:;!?"\']*|\\s(?=[(\'"])|[\'"](?=\\s|$)|$)', self.view.substr(to_end))
+      match = re.search(r'.*?([).,:;!?][).,:;!?"\']*|\\s(?=[(\'"])|[\'"](?=\\s|$)|$)', self.view.substr(to_end))
       if match:
         return ('collapse_move', len(match.group(0)))
 
diff --git a/apps/Sublime Text 4/Packages/User/Preferences.sublime-settings b/apps/Sublime Text 4/Packages/User/Preferences.sublime-settings
index f943b86..897f1ed 100644
--- a/apps/Sublime Text 4/Packages/User/Preferences.sublime-settings
+++ b/apps/Sublime Text 4/Packages/User/Preferences.sublime-settings
@@ -3,6 +3,7 @@
 	"font_size": 15,
 
 	"show_git_status": false,
+	"hide_new_tab_button": true,
 
 	"highlight_line": true,
 	"scroll_past_end": true,
diff --git a/apps/krita/krita-shortcuts.shortcuts b/apps/krita/krita-shortcuts.shortcuts
new file mode 100644
index 0000000..3ca342f
--- /dev/null
+++ b/apps/krita/krita-shortcuts.shortcuts
@@ -0,0 +1,26 @@
+[Shortcuts]
+KisToolSelectElliptical=none
+KisToolSelectOutline=U
+KisToolTransform=S
+KritaFill/KisToolFill=F; B
+KritaSelected/KisToolColorSampler=O
+KritaShape/KisToolBrush=P
+KritaShape/KisToolEllipse=none
+KritaTransform/KisToolMove=M
+RenameCurrentLayer=F2; R
+convert-to-path=none
+create_quick_group=Meta+G
+decrease_brush_size=Shift+[
+edit_redo=Ctrl+Shift+Z; Shift+J
+edit_undo=Ctrl+Z; J
+eraser_preset_action=K
+fullscreen=Meta+Ctrl+F
+increase_brush_size=Shift+]
+increase_opacity=none
+make_brush_color_darker=none
+pathpoint-join=none
+rotate_canvas_left=[
+rotate_canvas_right=]
+show_color_history=none
+show_common_colors=none
+toggle_layer_visibility=N
diff --git a/device/acme_post b/device/acme_post
new file mode 100755
index 0000000..e8a6bfe
--- /dev/null
+++ b/device/acme_post
@@ -0,0 +1,4 @@
+#!/bin/zsh
+
+# ACME
+# See acme_pre for info.
diff --git a/device/acme_pre b/device/acme_pre
new file mode 100755
index 0000000..5dd6e31
--- /dev/null
+++ b/device/acme_pre
@@ -0,0 +1,33 @@
+#!/bin/zsh
+
+# ACME shell
+#
+# Various configuration that makes ACME 'win' windows nicer
+# to use. This is treated like a device of its own, even
+# though it really isn't.
+
+awd zsh
+
+export EDITOR=E
+export NO_COLOR=1
+
+path=("$DOTFILES/scripts/acme" "$DOTFILES/scripts/acme_dynamic" $path)
+export PATH
+
+# Well, we tried this, but gpg-agent apparently insists on reading
+# from a strictly hard-coded file. No high jinks. It certainly doesn't
+# care about the PATH of the calling tty. This is just kept as reference.
+#
+# if [[ -v DEVICE_HAS_GPG ]]; then
+#     ln -s "$(which pinentry-tty)" "$DOTFILES/scripts/acme_dynamic/pinentry"
+# fi
+
+cd() {
+    if [ $# -eq 0 ]
+    then builtin cd && awd zsh
+    else builtin cd "$1" && awd zsh
+    fi
+}
+
+alias git='git -c color.ui=false --no-pager'
+alias ls='ls -1'
diff --git a/lib/plumbing b/lib/plumbing
new file mode 100644
index 0000000..58f333f
--- /dev/null
+++ b/lib/plumbing
@@ -0,0 +1,8 @@
+editor = acme
+
+type is text
+data matches '[0-9a-f]*[a-f][0-9a-f]*'
+data matches '([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]+)'
+plumb start rc -c 'ifs=''''; cd `{echo '$wdir' | perl -pe ''chomp if eof''}; cd `{git rev-parse --show-toplevel | perl -pe ''chomp if eof''} && git show '$1' | plumb -i -d edit -a ''action=showdata filename=+git'' '
+
+include basic
diff --git a/scripts/acme/E b/scripts/acme/E
new file mode 100755
index 0000000..7d79f0c
--- /dev/null
+++ b/scripts/acme/E
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+stat=`stat -f "%m" "$1" 2>&1`
+B "$@"
+while sleep 0.2s; do
+    nstat=`stat -f "%m" "$1" 2>&1`
+    if [ "x$stat" != "x$nstat" ]; then exit; fi
+done
diff --git a/scripts/acme/WT b/scripts/acme/WT
new file mode 100755
index 0000000..1db104d
--- /dev/null
+++ b/scripts/acme/WT
@@ -0,0 +1,3 @@
+#!/bin/zsh
+
+Wikitag </dev/stdin
\ No newline at end of file
diff --git a/scripts/acme/WT+ b/scripts/acme/WT+
new file mode 100755
index 0000000..e52d278
--- /dev/null
+++ b/scripts/acme/WT+
@@ -0,0 +1,3 @@
+#!/bin/zsh
+
+Wikitag -l </dev/stdin
\ No newline at end of file
diff --git a/scripts/acme/Wikitag b/scripts/acme/Wikitag
new file mode 100755
index 0000000..645bf1a
--- /dev/null
+++ b/scripts/acme/Wikitag
@@ -0,0 +1,36 @@
+#!/bin/zsh
+
+while getopts ":l" opt; do; case $opt in
+	l) label=1 ;;
+	*) exit 1
+esac; done
+
+cycle=( artist track album group )
+
+src=$(</dev/stdin)
+
+if [[ ! $src =~ '^\[\[.*\]\]$' ]]; then
+	printf '[[%s]]' "$src"; exit 0
+fi
+
+src=$src:s/[[//:s/]]//
+
+if [[ ! $src =~ '^[^ ]+:' ]]; then
+	if [[ -v label ]];
+	then printf '[[%s:%s|%s]]' ${cycle[1]} $(wikebab <<< "$src") "$src"
+	else printf '[[%s:%s]]' ${cycle[1]} $(wikebab <<< "$src")
+	fi; exit 0
+fi
+
+replacer=${src%:*}
+value=${src#*:}
+
+place=${cycle[(ie)$replacer]}
+length=${#cycle}
+if (( place >= length )); then
+	next=1
+else
+	(( next = place + 1 ))
+fi
+
+printf '[[%s:%s]]' ${cycle[$next]} $value
\ No newline at end of file
diff --git a/scripts/acme/acme-shell b/scripts/acme/acme-shell
new file mode 100755
index 0000000..a61c968
--- /dev/null
+++ b/scripts/acme/acme-shell
@@ -0,0 +1,3 @@
+#!/bin/zsh
+
+ACME=1 zsh "$@"
diff --git a/scripts/acme/wikebab b/scripts/acme/wikebab
new file mode 100755
index 0000000..3ba5c6e
--- /dev/null
+++ b/scripts/acme/wikebab
@@ -0,0 +1,24 @@
+#!/bin/zsh
+
+# Light version of getKebabCase which skips out on
+# a bunch of things we have no idea how to code with
+# sed regex, but aren't all too important for utility use.
+
+cat /dev/stdin | tr '[:upper:]' '[:lower:]' | sed \
+	-r \
+	-e 's/ /-/g' \
+	-e 's/&/-and-/g' \
+	-e 's/\+/-plus-/g' \
+	-e 's/%/-percent-/g' \
+	-e 's/(\b[^\s.-]{2,})\./$1-/g' \
+	-e 's/\.([^\s.-]{2,})\b/-$1/g' \
+	-e 's/[/@#$%*()_=,[\]{}|\\;:<>?`~]/-/g' \
+	-e 's/[áâäàå]/a/g' \
+	-e 's/[çč]/c/g' \
+	-e 's/[éêëè]/e/g' \
+	-e 's/[íîïì]/i/g' \
+	-e 's/[óôöò]/o/g' \
+	-e 's/[úûüù]/u/g' \
+	-e 's/[^a-z0-9-]//g' \
+	-e 's/-{2,}/-/g' \
+	-e 's/^-+|-+$//g'
\ No newline at end of file
diff --git a/scripts/acme/winn b/scripts/acme/winn
new file mode 100755
index 0000000..9bf7359
--- /dev/null
+++ b/scripts/acme/winn
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+cd "$1" && win "$SHELL"
diff --git a/scripts/acme_dynamic/readme.txt b/scripts/acme_dynamic/readme.txt
new file mode 100644
index 0000000..0c1c9dc
--- /dev/null
+++ b/scripts/acme_dynamic/readme.txt
@@ -0,0 +1,2 @@
+Binary scripts automatically prepared or linked for access within ACME.
+See device/acme_pre for details.
\ No newline at end of file
diff --git a/userstuff/hsmusic/Switch HSMusic websites.user.js b/userstuff/hsmusic/Switch HSMusic websites.user.js
index 47c2d0b..a36a138 100644
--- a/userstuff/hsmusic/Switch HSMusic websites.user.js
+++ b/userstuff/hsmusic/Switch HSMusic websites.user.js
@@ -59,12 +59,12 @@ customNavLink('L', 'http://localhost:8002');
 customNavLink('P', 'https://preview.hsmusic.wiki');
 customNavLink('R', 'https://hsmusic.wiki');
 
-let match = location.href.match(/album\/([^/]*)/);
+let match = location.href.match(/\/album\/([^/]*)/);
 if (match) {
     customNavLink('G', () => `https://github.com/hsmusic/hsmusic-data/tree/preview/album/${match[1]}.yaml`);
 }
 
-match = location.href.match(/track\/([^/]*)/);
+match = location.href.match(/\/track\/([^/]*)/);
 if (match) {
     const directory = getComputedStyle(document.body).getPropertyValue('--album-directory');
     customNavLink('G', () => `https://github.com/hsmusic/hsmusic-data/tree/preview/album/${directory}.yaml`);