diff --git a/README.md b/README.md index 184d2f7..e7d48bc 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,105 @@ -# Transparent Pipe : A terminal-based pipeline command +# Transparent Pipe(tp) [![Go Report Card](https://goreportcard.com/badge/github.com/minefuto/tp)](https://goreportcard.com/report/github.com/minefuto/tp) ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/minefuto/tp/build) ![GitHub release (latest by date)](https://img.shields.io/github/v/release/minefuto/tp) ![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/minefuto/tp) ![GitHub](https://img.shields.io/github/license/minefuto/tp) -This is a terminal-based application for interactively previews the stdin/stdout around the pipeline. +This project is inspired by [akavel/up](https://github.com/akavel/up). +`tp` is a terminal-based application for display the result of the command in real-time with each keystroke. -## Installation -``` -$ git clone https://github.com/minefuto/tp.git -$ cd tp -$ make install -``` +It provides two displays. +1. the input passed from last pipeline. +2. the output of the command currently being typed. -## Usage -### 1. commandline mode - +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. -Add the following to shell's config file. -``: Specify any key. -**Bash(`.bashrc`)** + + +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. +``: Specify any shortcut key. + +Bash ``` function transparent-pipe() { - READLINE_LINE=$(tp -c "${READLINE_LINE}|") + READLINE_LINE=$(tp -c "${READLINE_LINE}") READLINE_POINT=${#READLINE_LINE} } bind -x '"": transparent-pipe' ``` -**Zsh(`.zshrc`)** +Zsh ``` function transparent-pipe() { - BUFFER="$(tp -c "${BUFFER}|")" + BUFFER="$(tp -c "${BUFFER}")" CURSOR=$#BUFFER } zle -N transparent-pipeline bindkey "" transparent-pipe ``` -**Fish(`config.fish`)** +Fish ``` function transparent-pipe commandline | read -l buffer - commandline -r (tp -c "$buffer|") + commandline -r (tp -c "$buffer") commandline -f repaint end function fish_user_key_bindings bind "" 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 +This steps will install to `$GOPATH/bin`. +``` +$ git clone https://github.com/minefuto/tp.git +$ cd tp +$ make install +``` -### 2. stdin/stdout mode - +## 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 (Please see the "1. commandline mode") + -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") diff --git a/gif/mode1.gif b/gif/mode1.gif deleted file mode 100644 index 5fad93a..0000000 Binary files a/gif/mode1.gif and /dev/null differ diff --git a/gif/mode2.gif b/gif/mode2.gif deleted file mode 100644 index 3f65bb7..0000000 Binary files a/gif/mode2.gif and /dev/null differ diff --git a/gif/tp-shell.gif b/gif/tp-shell.gif new file mode 100644 index 0000000..606796f Binary files /dev/null and b/gif/tp-shell.gif differ diff --git a/gif/tp.gif b/gif/tp.gif new file mode 100644 index 0000000..8c643e0 Binary files /dev/null and b/gif/tp.gif differ