This commit is contained in:
Joakim
2026-10-12 22:54:45 +02:00
parent 972e941674
commit 4227383e5c
5 changed files with 69 additions and 53 deletions

View File

@@ -94,8 +94,7 @@ keys:
actions:
list-zip:
command:
- unzip -l <path>
- read -rp "Tryck Enter för att fortsätta..."
command: 'unzip -l <path> && read -rp "Enter to continue.." || read -rp "FAILED - Enter to continue..."'
move:
command: mv -v <path> <dir>
@@ -165,44 +164,42 @@ not clear the already marked paths.
When an action is triggered, TUI writes the generated commands to a temporary
file and exits with a private handoff status. The `tui()` Bash function then
executes them.
executes them in the parent Bash process.
For example:
When TUI is closed with `Ctrl+C`, the wrapper changes the parent Bash shell to
the directory where TUI was actually closed.
Action commands are handed to Bash as complete commands, so normal shell
operators such as `&&` and `||` work exactly as they do at the terminal. For
example:
```yaml
actions:
list-zip:
command: 'unzip -l <path> && read -rp "Enter to continue.." || read -rp "FAILED - Enter to continue..."'
```
The complete command is evaluated once. If `unzip` succeeds, the success
`read` is executed. If `unzip` fails, the failure `read` is executed.
For actions containing several separate commands, use a YAML list:
```yaml
actions:
example:
command:
- unzip -l <path>
- read -rp "Tryck Enter för att fortsätta..."
- command-one <path>
- command-two <path>
```
The flow is:
TUI is **not redrawn between commands belonging to the same action**. Each
command is inserted into Bash history. If a separate command fails, the
remaining commands in that action are not executed; TUI prints the exit code
and waits before returning to TUI.
```text
TUI
↓
unzip -l archive.zip
↓
read -rp "Tryck Enter..."
↓
TUI
```
TUI is **not redrawn between commands belonging to the same action**.
Every command is also inserted into Bash history. If one command fails, the
remaining commands in that action are not executed. TUI prints the exit code
and waits for:
```text
Tryck Enter för att fortsätta...
```
before returning to TUI, so an error cannot disappear immediately.
The shell wrapper uses `pushd`/`popd` so the command runs in the directory
shown by TUI without permanently changing the user's Bash working directory.
The shell wrapper uses `pushd`/`popd` so action commands run in the directory
shown by TUI without permanently changing the user's Bash directory during
the action.
## Security note