diff --git a/CHANGELOG.md b/CHANGELOG.md index fb258d6..a4fea95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,11 @@ A patch step for fixes, a minor step for additions and a major step when the lay ## [Unreleased] +### Added + +- A machine-only settings file that each shell loads after its topics when it exists: `~/.zshrc.local`, `~/.bashrc.local` on Linux bash and `~/.profile.local.ps1` on Windows. It is never committed, so a host name or an address stays on the machine it is for. `IDE_NODES` for `inodes` goes there. +- Five project layouts on macOS, Linux and Windows. `ifull` is the whole setup in one window: Neovim over a shell, btop and a scene, plus the lazygit window. It is the layout in the tmux README's picture, which no command opened before. `inodes` opens one tiled pane for each SSH host in `IDE_NODES`. `iwrite` is Neovim beside a live preview. `idata` is Neovim over a Python console and a shell. `idb` is Neovim over a database console and a shell. + ## [2.11.0] - 2026-11-08 ### Added diff --git a/shell/guides/documentation.md b/shell/guides/documentation.md index 3fbe1dc..36112bd 100644 --- a/shell/guides/documentation.md +++ b/shell/guides/documentation.md @@ -8,6 +8,7 @@ Detailed technical reference for this dotfiles repo. This covers how the loader - [Architecture](#architecture) - [Loader mechanics](#loader-mechanics) +- [Machine-only settings](#machine-only-settings) - [Navigation](#navigation) - [Git](#git) - [Repo management](#repo-management) @@ -114,6 +115,24 @@ Files are loaded in numerical order (01 before 02, etc.). A higher-numbered file --- +## Machine-only settings + +Each shell loads one more file after its topics when the file exists. It lives outside the repository and is never committed, so a host name, an address or a path that belongs to one machine stays on that machine. + +| Shell | File | +| --- | --- | +| zsh on macOS and Linux | `~/.zshrc.local` | +| bash on Linux | `~/.bashrc.local` | +| PowerShell on Windows | `~/.profile.local.ps1` | + +For example, the hosts `inodes` opens: + +```sh +export IDE_NODES="host-one host-two host-three host-four" +``` + +On Windows the same line is `$env:IDE_NODES = "host-one host-two host-three host-four"`. + ## Navigation Quick directory shortcuts. All three platforms define the same command names. @@ -637,6 +656,11 @@ in the session when Zacess Scenes is installed. The focus starts on the main pan | `ide [folder]` | Neovim, a shell, a scene and a lazygit window | | `idev [folder]` | Neovim over a shell, the dev server's logs (`npm run dev` or `php artisan serve`) and a scene, plus lazygit | | `imon [folder]` | btop (btop4win on Windows) beside `docker ps` and a scene | +| `ifull [folder]` | The whole setup in one window: Neovim over a shell, btop (btop4win on Windows) and a scene, plus lazygit | +| `inodes [folder]` | One pane for each SSH host in `IDE_NODES` (separated by spaces or colons), tiled and already connected | +| `iwrite [folder]` | Neovim beside a live preview (`npm run dev` for a site and glow for a folder of Markdown) and a scene | +| `idata [folder]` | Neovim over a Python console (ipython when installed), a shell and a scene, plus lazygit | +| `idb [folder]` | Neovim over a database console (lazysql when installed and `php artisan db` in a Laravel project otherwise), a shell and a scene, plus lazygit | | `ilab [folder]` | Neovim over a build shell, a serial monitor shell and a scene | | `ilog [folder]` | Two log shells side by side and a scene | | `iplay [folder]` | Zacess Games beside a scene | diff --git a/shell/linux/bashrc b/shell/linux/bashrc index 1a4d0e6..0cdbdc2 100644 --- a/shell/linux/bashrc +++ b/shell/linux/bashrc @@ -23,6 +23,12 @@ for _f in "$DOTFILES/linux/topics/"*.sh; do done unset _f +# settings that belong to this machine alone, such as the SSH hosts inodes opens (IDE_NODES). The +# file lives outside the repository and is never committed, so a host name or an address stays on +# the machine it is for. It loads after the topics, so it can override anything they set +# shellcheck disable=SC1091 +[[ -f "$HOME/.bashrc.local" ]] && source "$HOME/.bashrc.local" + # ============================================================================= # Welcome banner - printed after all topics load so colour variables are ready # ============================================================================= diff --git a/shell/linux/topics-zsh/21-tmux.zsh b/shell/linux/topics-zsh/21-tmux.zsh index 30fe80d..782466c 100644 --- a/shell/linux/topics-zsh/21-tmux.zsh +++ b/shell/linux/topics-zsh/21-tmux.zsh @@ -5,6 +5,11 @@ # ide [folder] Neovim, a shell, a scene and a lazygit window # idev [folder] Neovim over a shell, the dev server's logs and a scene, plus lazygit # imon [folder] btop beside docker ps and a scene +# ifull [folder] Neovim over a shell, btop and a scene, plus lazygit +# inodes [folder] one pane for each SSH host in IDE_NODES, tiled +# iwrite [folder] Neovim beside a live preview and a scene +# idata [folder] Neovim over a Python console, a shell and a scene, plus lazygit +# idb [folder] Neovim over a database console, a shell and a scene, plus lazygit # ilab [folder] Neovim over a build shell, a serial monitor shell and a scene # ilog [folder] two log shells side by side and a scene # iplay [folder] Zacess Games beside a scene @@ -181,6 +186,117 @@ imon() { _ide_show "$monitor" } +# ifull: the whole setup in one window. Neovim on top (60 percent) over a row of a shell, btop +# (or else htop or top) and a scene, plus the lazygit window. btop opens on its third preset, the +# processor and the network, which is what fits a pane this narrow +ifull() { + local dir name width height editor shell monitor + _ide_open ifull -full "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + shell="$(_ide_split "$editor" -v 40%)" + # the bottom row is shell 33, btop 33 and scene 34 percent: btop takes 67 percent of the row, + # then the scene takes half of that + monitor="$(_ide_split "$shell" -h 67%)" + _ide_scene "$monitor" -h 50% + if command -v btop >/dev/null 2>&1; then + tmux send-keys -t "$monitor" 'btop -p 3' Enter + elif command -v htop >/dev/null 2>&1; then + tmux send-keys -t "$monitor" htop Enter + else + tmux send-keys -t "$monitor" top Enter + fi + _ide_git + _ide_show "$editor" +} + +# inodes: every machine at once. One pane for each SSH host named in IDE_NODES (separated by +# spaces or colons), tiled to fill the window, each already connected. The session is named after +# the folder like the others, so one project can keep its own set of machines open +inodes() { + local dir name width height first pane host count + if [ -z "$IDE_NODES" ]; then + printf 'inodes: set IDE_NODES to the SSH hosts to open, for example IDE_NODES="node1 node2 node3 node4"\n' >&2 + return 1 + fi + _ide_open inodes -nodes "$1" || { [ $? -eq 2 ] && _ide_show; return; } + first="$(_ide_main nodes)" + count=0 + # read line by line, since zsh does not split a plain variable into words as bash does + printf '%s\n' "$IDE_NODES" | tr -s ' :' '\n' | while read -r host; do + [ -n "$host" ] || continue + if [ "$count" -eq 0 ]; then + pane="$first" + else + pane="$(_ide_split "$first" -h 50%)" + # tiled after every split, so a fifth or sixth pane still has room to open + tmux select-layout -t "$first" tiled >/dev/null + fi + tmux send-keys -t "$pane" "ssh $host" Enter + count=$((count + 1)) + done + _ide_show "$first" +} + +# iwrite: writing. Neovim on the left (60 percent) beside a live preview over a scene. The preview +# runs npm run dev when package.json has a dev script, so a site shows the page being written, +# glow for a folder of Markdown when it is installed and is a plain shell otherwise +iwrite() { + local dir name width height editor side + _ide_open iwrite -write "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main write)" + tmux send-keys -t "$editor" 'nvim .' Enter + side="$(_ide_split "$editor" -h 40%)" + _ide_scene "$side" -v 30% + if [ -f "$dir/package.json" ] && grep -q '"dev"[[:space:]]*:' "$dir/package.json"; then + tmux send-keys -t "$side" 'npm run dev' Enter + elif command -v glow >/dev/null 2>&1; then + tmux send-keys -t "$side" 'glow .' Enter + fi + _ide_show "$editor" +} + +# idata: data and machine learning. Neovim on top (60 percent) over a row of a Python console +# (ipython when it is installed), a shell and a scene, plus the lazygit window +idata() { + local dir name width height editor console shell + _ide_open idata -data "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + console="$(_ide_split "$editor" -v 40%)" + # the bottom row is console 40, shell 36 and scene 24 percent + shell="$(_ide_split "$console" -h 60%)" + _ide_scene "$shell" -h 40% + if command -v ipython >/dev/null 2>&1; then + tmux send-keys -t "$console" ipython Enter + elif command -v python3 >/dev/null 2>&1; then + tmux send-keys -t "$console" python3 Enter + fi + _ide_git + _ide_show "$editor" +} + +# idb: database work. Neovim on top (60 percent) over a row of a database console, a shell and a +# scene, plus the lazygit window. The console runs lazysql when it is installed, php artisan db in +# a Laravel project and is a plain shell otherwise, since which database to open differs per project +idb() { + local dir name width height editor console shell + _ide_open idb -db "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + console="$(_ide_split "$editor" -v 40%)" + # the bottom row is console 50, shell 30 and scene 20 percent + shell="$(_ide_split "$console" -h 50%)" + _ide_scene "$shell" -h 40% + if command -v lazysql >/dev/null 2>&1; then + tmux send-keys -t "$console" lazysql Enter + elif [ -f "$dir/artisan" ]; then + tmux send-keys -t "$console" 'php artisan db' Enter + fi + _ide_git + _ide_show "$editor" +} + # ilab: embedded and lab work. Neovim on top (65 percent) over a row of a build shell ready for # make or avr-gcc, a serial monitor shell and a scene. Nothing runs by itself in the bottom row, # since the build and the serial port differ per board diff --git a/shell/linux/topics/21-tmux.sh b/shell/linux/topics/21-tmux.sh index 30fe80d..782466c 100644 --- a/shell/linux/topics/21-tmux.sh +++ b/shell/linux/topics/21-tmux.sh @@ -5,6 +5,11 @@ # ide [folder] Neovim, a shell, a scene and a lazygit window # idev [folder] Neovim over a shell, the dev server's logs and a scene, plus lazygit # imon [folder] btop beside docker ps and a scene +# ifull [folder] Neovim over a shell, btop and a scene, plus lazygit +# inodes [folder] one pane for each SSH host in IDE_NODES, tiled +# iwrite [folder] Neovim beside a live preview and a scene +# idata [folder] Neovim over a Python console, a shell and a scene, plus lazygit +# idb [folder] Neovim over a database console, a shell and a scene, plus lazygit # ilab [folder] Neovim over a build shell, a serial monitor shell and a scene # ilog [folder] two log shells side by side and a scene # iplay [folder] Zacess Games beside a scene @@ -181,6 +186,117 @@ imon() { _ide_show "$monitor" } +# ifull: the whole setup in one window. Neovim on top (60 percent) over a row of a shell, btop +# (or else htop or top) and a scene, plus the lazygit window. btop opens on its third preset, the +# processor and the network, which is what fits a pane this narrow +ifull() { + local dir name width height editor shell monitor + _ide_open ifull -full "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + shell="$(_ide_split "$editor" -v 40%)" + # the bottom row is shell 33, btop 33 and scene 34 percent: btop takes 67 percent of the row, + # then the scene takes half of that + monitor="$(_ide_split "$shell" -h 67%)" + _ide_scene "$monitor" -h 50% + if command -v btop >/dev/null 2>&1; then + tmux send-keys -t "$monitor" 'btop -p 3' Enter + elif command -v htop >/dev/null 2>&1; then + tmux send-keys -t "$monitor" htop Enter + else + tmux send-keys -t "$monitor" top Enter + fi + _ide_git + _ide_show "$editor" +} + +# inodes: every machine at once. One pane for each SSH host named in IDE_NODES (separated by +# spaces or colons), tiled to fill the window, each already connected. The session is named after +# the folder like the others, so one project can keep its own set of machines open +inodes() { + local dir name width height first pane host count + if [ -z "$IDE_NODES" ]; then + printf 'inodes: set IDE_NODES to the SSH hosts to open, for example IDE_NODES="node1 node2 node3 node4"\n' >&2 + return 1 + fi + _ide_open inodes -nodes "$1" || { [ $? -eq 2 ] && _ide_show; return; } + first="$(_ide_main nodes)" + count=0 + # read line by line, since zsh does not split a plain variable into words as bash does + printf '%s\n' "$IDE_NODES" | tr -s ' :' '\n' | while read -r host; do + [ -n "$host" ] || continue + if [ "$count" -eq 0 ]; then + pane="$first" + else + pane="$(_ide_split "$first" -h 50%)" + # tiled after every split, so a fifth or sixth pane still has room to open + tmux select-layout -t "$first" tiled >/dev/null + fi + tmux send-keys -t "$pane" "ssh $host" Enter + count=$((count + 1)) + done + _ide_show "$first" +} + +# iwrite: writing. Neovim on the left (60 percent) beside a live preview over a scene. The preview +# runs npm run dev when package.json has a dev script, so a site shows the page being written, +# glow for a folder of Markdown when it is installed and is a plain shell otherwise +iwrite() { + local dir name width height editor side + _ide_open iwrite -write "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main write)" + tmux send-keys -t "$editor" 'nvim .' Enter + side="$(_ide_split "$editor" -h 40%)" + _ide_scene "$side" -v 30% + if [ -f "$dir/package.json" ] && grep -q '"dev"[[:space:]]*:' "$dir/package.json"; then + tmux send-keys -t "$side" 'npm run dev' Enter + elif command -v glow >/dev/null 2>&1; then + tmux send-keys -t "$side" 'glow .' Enter + fi + _ide_show "$editor" +} + +# idata: data and machine learning. Neovim on top (60 percent) over a row of a Python console +# (ipython when it is installed), a shell and a scene, plus the lazygit window +idata() { + local dir name width height editor console shell + _ide_open idata -data "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + console="$(_ide_split "$editor" -v 40%)" + # the bottom row is console 40, shell 36 and scene 24 percent + shell="$(_ide_split "$console" -h 60%)" + _ide_scene "$shell" -h 40% + if command -v ipython >/dev/null 2>&1; then + tmux send-keys -t "$console" ipython Enter + elif command -v python3 >/dev/null 2>&1; then + tmux send-keys -t "$console" python3 Enter + fi + _ide_git + _ide_show "$editor" +} + +# idb: database work. Neovim on top (60 percent) over a row of a database console, a shell and a +# scene, plus the lazygit window. The console runs lazysql when it is installed, php artisan db in +# a Laravel project and is a plain shell otherwise, since which database to open differs per project +idb() { + local dir name width height editor console shell + _ide_open idb -db "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + console="$(_ide_split "$editor" -v 40%)" + # the bottom row is console 50, shell 30 and scene 20 percent + shell="$(_ide_split "$console" -h 50%)" + _ide_scene "$shell" -h 40% + if command -v lazysql >/dev/null 2>&1; then + tmux send-keys -t "$console" lazysql Enter + elif [ -f "$dir/artisan" ]; then + tmux send-keys -t "$console" 'php artisan db' Enter + fi + _ide_git + _ide_show "$editor" +} + # ilab: embedded and lab work. Neovim on top (65 percent) over a row of a build shell ready for # make or avr-gcc, a serial monitor shell and a scene. Nothing runs by itself in the bottom row, # since the build and the serial port differ per board diff --git a/shell/linux/zshrc b/shell/linux/zshrc index 86a4629..e427b5f 100644 --- a/shell/linux/zshrc +++ b/shell/linux/zshrc @@ -48,6 +48,12 @@ for _f in "$DOTFILES/linux/topics-zsh/"*.zsh; do done unset _f +# settings that belong to this machine alone, such as the SSH hosts inodes opens (IDE_NODES). The +# file lives outside the repository and is never committed, so a host name or an address stays on +# the machine it is for. It loads after the topics, so it can override anything they set +# shellcheck disable=SC1091 +[[ -f "$HOME/.zshrc.local" ]] && source "$HOME/.zshrc.local" + # ============================================================================= # Welcome banner - printed after all topics load so colour variables are ready # ============================================================================= diff --git a/shell/mac/topics/21-tmux.zsh b/shell/mac/topics/21-tmux.zsh index d1394a4..4d4c380 100644 --- a/shell/mac/topics/21-tmux.zsh +++ b/shell/mac/topics/21-tmux.zsh @@ -7,6 +7,11 @@ # ide [folder] Neovim, a shell, a scene and a lazygit window # idev [folder] Neovim over a shell, the dev server's logs and a scene, plus lazygit # imon [folder] btop beside docker ps and a scene +# ifull [folder] Neovim over a shell, btop and a scene, plus lazygit +# inodes [folder] one pane for each SSH host in IDE_NODES, tiled +# iwrite [folder] Neovim beside a live preview and a scene +# idata [folder] Neovim over a Python console, a shell and a scene, plus lazygit +# idb [folder] Neovim over a database console, a shell and a scene, plus lazygit # ilab [folder] Neovim over a build shell, a serial monitor shell and a scene # ilog [folder] two log shells side by side and a scene # iplay [folder] Zacess Games beside a scene @@ -210,6 +215,117 @@ imon() { _ide_show "$monitor" } +# ifull: the whole setup in one window. Neovim on top (60 percent) over a row of a shell, btop +# (or else htop or top) and a scene, plus the lazygit window. btop opens on its third preset, the +# processor and the network, which is what fits a pane this narrow +ifull() { + local dir name width height editor shell monitor + _ide_open ifull -full "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + shell="$(_ide_split "$editor" -v 40%)" + # the bottom row is shell 33, btop 33 and scene 34 percent: btop takes 67 percent of the row, + # then the scene takes half of that + monitor="$(_ide_split "$shell" -h 67%)" + _ide_scene "$monitor" -h 50% + if command -v btop >/dev/null 2>&1; then + tmux send-keys -t "$monitor" 'btop -p 3' Enter + elif command -v htop >/dev/null 2>&1; then + tmux send-keys -t "$monitor" htop Enter + else + tmux send-keys -t "$monitor" top Enter + fi + _ide_git + _ide_show "$editor" +} + +# inodes: every machine at once. One pane for each SSH host named in IDE_NODES (separated by +# spaces or colons), tiled to fill the window, each already connected. The session is named after +# the folder like the others, so one project can keep its own set of machines open +inodes() { + local dir name width height first pane host count + if [ -z "$IDE_NODES" ]; then + printf 'inodes: set IDE_NODES to the SSH hosts to open, for example IDE_NODES="node1 node2 node3 node4"\n' >&2 + return 1 + fi + _ide_open inodes -nodes "$1" || { [ $? -eq 2 ] && _ide_show; return; } + first="$(_ide_main nodes)" + count=0 + # read line by line, since zsh does not split a plain variable into words as bash does + printf '%s\n' "$IDE_NODES" | tr -s ' :' '\n' | while read -r host; do + [ -n "$host" ] || continue + if [ "$count" -eq 0 ]; then + pane="$first" + else + pane="$(_ide_split "$first" -h 50%)" + # tiled after every split, so a fifth or sixth pane still has room to open + tmux select-layout -t "$first" tiled >/dev/null + fi + tmux send-keys -t "$pane" "ssh $host" Enter + count=$((count + 1)) + done + _ide_show "$first" +} + +# iwrite: writing. Neovim on the left (60 percent) beside a live preview over a scene. The preview +# runs npm run dev when package.json has a dev script, so a site shows the page being written, +# glow for a folder of Markdown when it is installed and is a plain shell otherwise +iwrite() { + local dir name width height editor side + _ide_open iwrite -write "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main write)" + tmux send-keys -t "$editor" 'nvim .' Enter + side="$(_ide_split "$editor" -h 40%)" + _ide_scene "$side" -v 30% + if [ -f "$dir/package.json" ] && grep -q '"dev"[[:space:]]*:' "$dir/package.json"; then + tmux send-keys -t "$side" 'npm run dev' Enter + elif command -v glow >/dev/null 2>&1; then + tmux send-keys -t "$side" 'glow .' Enter + fi + _ide_show "$editor" +} + +# idata: data and machine learning. Neovim on top (60 percent) over a row of a Python console +# (ipython when it is installed), a shell and a scene, plus the lazygit window +idata() { + local dir name width height editor console shell + _ide_open idata -data "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + console="$(_ide_split "$editor" -v 40%)" + # the bottom row is console 40, shell 36 and scene 24 percent + shell="$(_ide_split "$console" -h 60%)" + _ide_scene "$shell" -h 40% + if command -v ipython >/dev/null 2>&1; then + tmux send-keys -t "$console" ipython Enter + elif command -v python3 >/dev/null 2>&1; then + tmux send-keys -t "$console" python3 Enter + fi + _ide_git + _ide_show "$editor" +} + +# idb: database work. Neovim on top (60 percent) over a row of a database console, a shell and a +# scene, plus the lazygit window. The console runs lazysql when it is installed, php artisan db in +# a Laravel project and is a plain shell otherwise, since which database to open differs per project +idb() { + local dir name width height editor console shell + _ide_open idb -db "$1" || { [ $? -eq 2 ] && _ide_show; return; } + editor="$(_ide_main editor)" + tmux send-keys -t "$editor" 'nvim .' Enter + console="$(_ide_split "$editor" -v 40%)" + # the bottom row is console 50, shell 30 and scene 20 percent + shell="$(_ide_split "$console" -h 50%)" + _ide_scene "$shell" -h 40% + if command -v lazysql >/dev/null 2>&1; then + tmux send-keys -t "$console" lazysql Enter + elif [ -f "$dir/artisan" ]; then + tmux send-keys -t "$console" 'php artisan db' Enter + fi + _ide_git + _ide_show "$editor" +} + # ilab: embedded and lab work. Neovim on top (65 percent) over a row of a build shell ready for # make or avr-gcc, a serial monitor shell and a scene. Nothing runs by itself in the bottom row, # since the build and the serial port differ per board diff --git a/shell/mac/zshrc b/shell/mac/zshrc index 38f4269..36af941 100644 --- a/shell/mac/zshrc +++ b/shell/mac/zshrc @@ -23,6 +23,12 @@ for _f in "$DOTFILES/mac/topics/"*.zsh; do done unset _f +# settings that belong to this machine alone, such as the SSH hosts inodes opens (IDE_NODES). The +# file lives outside the repository and is never committed, so a host name or an address stays on +# the machine it is for. It loads after the topics, so it can override anything they set +# shellcheck disable=SC1091 +[[ -f "$HOME/.zshrc.local" ]] && source "$HOME/.zshrc.local" + # ============================================================================= # Welcome banner - printed after all topics load so colour variables are ready # ============================================================================= diff --git a/shell/windows/Microsoft.PowerShell_profile.ps1 b/shell/windows/Microsoft.PowerShell_profile.ps1 index ed0a83d..06cd3e6 100644 --- a/shell/windows/Microsoft.PowerShell_profile.ps1 +++ b/shell/windows/Microsoft.PowerShell_profile.ps1 @@ -40,6 +40,13 @@ try { foreach ($topic in $topics) { . $topic.FullName } } +# settings that belong to this machine alone, such as the SSH hosts inodes opens (IDE_NODES). the +# file lives outside the repository and is never committed, so a host name or an address stays on +# the machine it is for. it loads after the topics, so it can override anything they set +$local = Join-Path $HOME '.profile.local.ps1' +if (Test-Path -LiteralPath $local) { . $local } +Remove-Variable local + # ============================================================================= # Welcome banner - printed after all topics load so welcome is defined # ============================================================================= diff --git a/shell/windows/cmd/README.md b/shell/windows/cmd/README.md index 37932f5..9e47a4f 100644 --- a/shell/windows/cmd/README.md +++ b/shell/windows/cmd/README.md @@ -33,7 +33,7 @@ A macro works only at the prompt, not inside a batch file. It takes its argument ## Not ported -387 functions are macros in Command Prompt. These 297 are not: +387 functions are macros in Command Prompt. These 302 are not: | Topic | Function | Why it stays in PowerShell | | --- | --- | --- | @@ -259,6 +259,11 @@ A macro works only at the prompt, not inside a batch file. It takes its argument | `21-tmux.ps1` | `idev` | spans several lines of PowerShell | | `21-tmux.ps1` | `_ide_scripts` | spans several lines of PowerShell | | `21-tmux.ps1` | `imon` | spans several lines of PowerShell | +| `21-tmux.ps1` | `ifull` | spans several lines of PowerShell | +| `21-tmux.ps1` | `inodes` | spans several lines of PowerShell | +| `21-tmux.ps1` | `iwrite` | spans several lines of PowerShell | +| `21-tmux.ps1` | `idata` | spans several lines of PowerShell | +| `21-tmux.ps1` | `idb` | spans several lines of PowerShell | | `21-tmux.ps1` | `ilab` | spans several lines of PowerShell | | `21-tmux.ps1` | `ilog` | spans several lines of PowerShell | | `21-tmux.ps1` | `iplay` | spans several lines of PowerShell | diff --git a/shell/windows/topics/21-tmux.ps1 b/shell/windows/topics/21-tmux.ps1 index 4002594..00fcf15 100644 --- a/shell/windows/topics/21-tmux.ps1 +++ b/shell/windows/topics/21-tmux.ps1 @@ -8,6 +8,11 @@ # ide [folder] nvim, a shell, a scene and a lazygit window # idev [folder] nvim over a shell, the dev server's logs and a scene, plus lazygit # imon [folder] btop4win beside docker ps and a scene +# ifull [folder] nvim over a shell, btop4win and a scene, plus lazygit +# inodes [folder] one pane for each SSH host in IDE_NODES, tiled +# iwrite [folder] nvim beside a live preview and a scene +# idata [folder] nvim over a Python console, a shell and a scene, plus lazygit +# idb [folder] nvim over a database console, a shell and a scene, plus lazygit # ilab [folder] nvim over a build shell, a serial monitor shell and a scene # ilog [folder] two log shells side by side and a scene # iplay [folder] Zacess Games beside a scene @@ -234,6 +239,106 @@ function imon { _ide_show $s '-L' } +# ifull: the whole setup in one window. nvim on top (60 percent) over a row of a shell, btop4win +# (or btop) and a scene, plus the lazygit window. the middle pane is a plain shell when neither +# is installed +function ifull { + param([string]$Path = '.') + $s = _ide_open 'ifull' '-full' $Path; if (-not $s) { return }; if ($s.Open) { return _ide_show $s } + _ide_main $s 'editor' + _ide_send $s 'nvim .' + _ide_split $s '-v' '40%' + # the bottom row is shell 33, btop 33 and scene 34 percent: btop takes 67 percent of the row, + # then the scene takes half of that + _ide_split $s '-h' '67%' + _ide_scene $s '-h' '50%' + $top = Get-Command btop4win, btop -ErrorAction SilentlyContinue | Select-Object -First 1 + if ($top) { _ide_send $s $top.Name } + _ide_git $s + _ide_show $s '-U' +} + +# inodes: every machine at once. one pane for each SSH host named in IDE_NODES (separated by +# spaces or colons), tiled to fill the window, each already connected +function inodes { + param([string]$Path = '.') + $nodes = @("$env:IDE_NODES" -split '[\s:]+' | Where-Object { $_ }) + if (-not $nodes) { + Write-Warning 'inodes: set IDE_NODES to the SSH hosts to open, for example $env:IDE_NODES = "node1 node2 node3 node4"' + return + } + $s = _ide_open 'inodes' '-nodes' $Path; if (-not $s) { return }; if ($s.Open) { return _ide_show $s } + _ide_main $s 'nodes' + $first = $true + foreach ($node in $nodes) { + if (-not $first) { + _ide_split $s '-h' '50%' + # tiled after every split, so a fifth or sixth pane still has room to open + _psmux_out select-layout -t $s.Pane tiled + } + _ide_send $s "ssh $node" + $first = $false + } + _ide_show $s +} + +# iwrite: writing. nvim on the left (60 percent) beside a live preview over a scene. the preview +# runs npm run dev when package.json has a dev script, glow for a folder of Markdown when it is +# installed and is a plain shell otherwise +function iwrite { + param([string]$Path = '.') + $s = _ide_open 'iwrite' '-write' $Path; if (-not $s) { return }; if ($s.Open) { return _ide_show $s } + _ide_main $s 'write' + _ide_send $s 'nvim .' + _ide_split $s '-h' '40%' + _ide_scene $s '-v' '30%' + $scripts = _ide_scripts $s + if ($scripts.dev) { + _ide_send $s 'npm run dev' + } elseif (Get-Command glow -ErrorAction SilentlyContinue) { + _ide_send $s 'glow .' + } + _ide_show $s '-L' +} + +# idata: data and machine learning. nvim on top (60 percent) over a row of a Python console +# (ipython when it is installed), a shell and a scene, plus the lazygit window +function idata { + param([string]$Path = '.') + $s = _ide_open 'idata' '-data' $Path; if (-not $s) { return }; if ($s.Open) { return _ide_show $s } + _ide_main $s 'editor' + _ide_send $s 'nvim .' + _ide_split $s '-v' '40%' + $python = Get-Command ipython, python -ErrorAction SilentlyContinue | Select-Object -First 1 + if ($python) { _ide_send $s $python.Name } + # the bottom row is console 40, shell 36 and scene 24 percent + _ide_split $s '-h' '60%' + _ide_scene $s '-h' '40%' + _ide_git $s + _ide_show $s '-U' +} + +# idb: database work. nvim on top (60 percent) over a row of a database console, a shell and a +# scene, plus the lazygit window. the console runs lazysql when it is installed, php artisan db in +# a Laravel project and is a plain shell otherwise +function idb { + param([string]$Path = '.') + $s = _ide_open 'idb' '-db' $Path; if (-not $s) { return }; if ($s.Open) { return _ide_show $s } + _ide_main $s 'editor' + _ide_send $s 'nvim .' + _ide_split $s '-v' '40%' + if (Get-Command lazysql -ErrorAction SilentlyContinue) { + _ide_send $s 'lazysql' + } elseif (Test-Path -LiteralPath (Join-Path $s.Dir 'artisan')) { + _ide_send $s 'php artisan db' + } + # the bottom row is console 50, shell 30 and scene 20 percent + _ide_split $s '-h' '50%' + _ide_scene $s '-h' '40%' + _ide_git $s + _ide_show $s '-U' +} + # ilab: embedded and lab work. nvim on top (65 percent) over a row of a build shell ready for make # or avr-gcc, a serial monitor shell and a scene. nothing runs by itself in the bottom row, since # the build and the serial port differ per board