feat(docs): aerospace keybindings and update code

This commit is contained in:
2025-01-15 15:33:01 +02:00
parent be3a68fecb
commit 1288599b1f
3 changed files with 138 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
# aerospace keybindings
## main
| Key | Command(s) and actions |
|-----------------|-----------------------------------------------|
| alt-a | mode apps |
| alt-h | focus left |
| alt-j | focus down |
| alt-k | focus up |
| alt-l | focus right |
| alt-m | mode move |
| alt-s | mode service |
| alt-shift-1 | workspace 1 |
| alt-shift-2 | workspace 2 |
| alt-shift-tab | workspace-back-and-forth |
| ctrl-shift-1 | move-node-to-workspace 1 |
| ctrl-shift-2 | move-node-to-workspace 2 |
| ctrl-shift-tab | move-workspace-to-monitor --wrap-around prev |
## apps
| Key | Command(s) and actions |
|------|----------------------------------------------------------------------|
| b | exec-and-forget open -a /Applications/Brave Browser.app; mode main |
| c | exec-and-forget open -a /Applications/Ferdium.app; mode main |
| esc | reload-config; mode main |
| g | exec-and-forget open -a /Applications/Ghostty.app; mode main |
| o | exec-and-forget open -a /Applications/Obsidian.app; mode main |
| s | exec-and-forget open -a /Applications/Slack.app; mode main |
| t | exec-and-forget open -a /Applications/TIDAL.app; mode main |
| w | exec-and-forget open -a /Applications/WezTerm.app; mode main |
## move
| Key | Command(s) and actions |
|--------------|--------------------------------------------------|
| 1 | move-node-to-workspace 1 --focus-follows-window |
| 2 | move-node-to-workspace 2 --focus-follows-window |
| ctrl-h | resize smart -70 |
| ctrl-l | resize smart +70 |
| esc | reload-config; mode main |
| h | move left |
| j | move down |
| k | move up |
| l | move right |
| r | flatten-workspace-tree; mode main |
| shift-h | join-with left |
| shift-j | join-with down |
| shift-k | join-with up |
| shift-l | join-with right |
| shift-left | resize smart +70 |
| shift-right | resize smart -70 |
## service
| Key | Command(s) and actions |
|------------|-------------------------------------------|
| backspace | close-all-windows-but-current; mode main |
| esc | reload-config; mode main |
| f | layout floating tiling; mode main |
| r | flatten-workspace-tree; mode main |
File generated: 2025-01-15 13:32:41
Config file: [config/aerospace/aerospace.toml](./../config/aerospace/aerospace.toml)

View File

@@ -436,6 +436,7 @@ section_helpers()
"colors:Show colors"
"env:Show environment variables"
"functions:Show functions"
"aerospace:Show aerospace keybindings"
"nvim:Show nvim keybindings"
'path:Show $PATH dir by dir'
"tmux:Show tmux keybindings"
@@ -494,6 +495,7 @@ section_helpers()
"env") env | sort ;;
"functions") declare -F ;;
"aerospace") cat "$DOTFILES/docs/aerospace-keybindings.md" ;;
"nvim") cat "$DOTFILES/docs/nvim-keybindings.md" ;;
"tmux") cat "$DOTFILES/docs/tmux-keybindings.md" ;;
"wezterm") cat "$DOTFILES/docs/wezterm-keybindings.md" ;;
@@ -507,6 +509,7 @@ section_docs()
MENU=(
"all:Update all keybindings documentations"
"aerospace:Update aerospace keybindings documentation"
"tmux:Update tmux keybindings documentation"
"nvim:Update nvim keybindings documentation"
"wezterm:Update wezterm keybindings documentation"
@@ -514,10 +517,12 @@ section_docs()
case "$1" in
all)
$0 docs aerospace
$0 docs tmux
$0 docs nvim
$0 docs wezterm
;;
aerospace) bash "$DOTFILES/scripts/create-aerospace-keymaps.php" ;;
tmux) bash "$DOTFILES/local/bin/x-dfm-docs-xterm-keybindings" ;;
nvim) bash "$DOTFILES/scripts/create-nvim-keymaps.sh" ;;
wezterm) bash "$DOTFILES/scripts/create-wezterm-keymaps.sh" ;;

View File

@@ -0,0 +1,67 @@
#!/usr/bin/env php
<?php
// @description Create file containing key mappings for aerospace
// Usage: ./create-aerospace-keymaps.sh
// vim: ft=php ts=4 sw=4 sts=4 sr et
$dotfiles_env = getenv("DOTFILES") ?? '~/.dotfiles';
$dest = "$dotfiles_env/docs/aerospace-keybindings.md";
exec("aerospace config --get mode --json", $output);
$output = join(' ', $output);
$config = json_decode($output, true);
$main = $config['main'];
unset($config['main']);
function process_section(string $title, array $array)
{
$bindings = $array['binding'] ?? [];
ksort($bindings);
$output = [];
$output[] = sprintf("\n## %s\n", $title);
$k_len = max(array_map('strlen', array_keys($bindings)));
$v_len = max(array_map('strlen', array_values($bindings)));
$output[] = sprintf(
"| %s | %s |",
str_pad('Key', $k_len + 1),
str_pad('Command(s) and actions', $v_len + 1)
);
$output[] = sprintf(
"|%s|%s|",
str_repeat('-', $k_len + 3),
str_repeat('-', $v_len + 3)
);
foreach ($bindings as $key => $value) {
$k = str_pad($key, $k_len + 1);
$v = str_pad($value, $v_len + 1);
$output[] = sprintf("| %s | %s |", $k, $v);
}
return implode("\n", $output);
}
$contents = [];
$contents[] = "# aerospace keybindings";
$contents[] = process_section("main", $main);
ksort($config);
foreach ($config as $mode => $bindings) {
$contents[] = process_section($mode, $bindings);
}
$contents[] = "\nFile generated: " . date("Y-m-d H:i:s") . "\n";
$config_file_name = 'config/aerospace/aerospace.toml';
$config_file_source = './../config/aerospace/aerospace.toml';
$contents[] = "Config file: [$config_file_name]($config_file_source)\n";
$file = implode("\n", $contents);
file_put_contents($dest, $file);