Transparent Pipe(tp)
This project is inspired by akavel/up.
tp
is a terminal-based application for display the result of the command in real-time with each keystroke.
It provides two displays.
- the input passed from last pipeline.
- the output of the command currently being typed.
You can consider the next commands while watching the input passed from pipeline.
These will help you create complex commands including pipelines for get the ideal output with try and error.
Please type Enter when you completed to create command in tp
.
Then, tp
returns the full result of the command as stdout/stderr.
Also, tp
can collaborate with the shell.
By typing a shortcut key, you can start tp
by capturing the command being typed into shell.
And the command being typed into tp
return to shell when type Enter.
If you want to collaborate with the shell, please add the following to shell's config file.
<key>
: Specify any shortcut key.
Bash
function transparent-pipe() {
READLINE_LINE=$(tp -c "${READLINE_LINE}")
READLINE_POINT=${#READLINE_LINE}
}
bind -x '"<key>": transparent-pipe'
Zsh
function transparent-pipe() {
BUFFER="$(tp -c "${BUFFER}")"
CURSOR=$#BUFFER
}
zle -N transparent-pipeline
bindkey "<key>" transparent-pipe
Fish
function transparent-pipe
commandline | read -l buffer
commandline -r (tp -c "$buffer")
commandline -f repaint
end
function fish_user_key_bindings
bind "<key>" transparent-pipe
end
Warning!!!
tp
executes the command being typed with each keystroke. There is possibility to execute dangerous commands.
So, create/delete operations(such as mkdir
, rm
) should not be typed because you might execute a careless command.
tp
is not designed for such operations.
But I'm afraid of typo.
tp
provides a feature of prevent execution a specific commands.
Please create block command list in $TP_BLOCK_COMMAND
with :
as delimiter. For example,
export TP_BLOCK_COMMAND='mkdir:rmdir:rm:mv'
Also, disable keystroke of redirection(<
, >
) in tp
for the same reason.
Installation
$ go install github.com/minefuto/tp@latest
Keybindings
operation |
key |
Move left(one char) |
← / Ctrl-B |
Move right(one char) |
→ / Ctrl-F |
Move left(one word) |
Alt← / Alt-B |
Move right(one word) |
Alt→ / Alt-F |
Move begin of the line |
Home / Ctrl-A |
Move end of the line |
End / Ctrl-E |
Delete one char before the cursor |
Backspace / Ctrl-H |
Delete one char after the cursor |
Delete / Ctrl-D |
Delete one word before the cursor |
Ctrl-W |
Delete from the cursor to end of the line |
Ctrl-K |
Delete all line |
Ctrl-U |
Options
> tp -h
Usage of tp:
-c, --command Return commandline text (for collaborate with the shell)
-h, --help Show help
--horizontal Split the view horizontally
-s, --shell string Specify the shell to use (default "$SHELL")
-v, --version Show version
Supported OS
macOS, Linux