|
1 |
| -# Transparent Pipe : A terminal-based pipeline command |
| 1 | +# Transparent Pipe(tp) |
2 | 2 | [](https://goreportcard.com/report/github.com/minefuto/tp)
|
3 | 3 | 
|
4 | 4 | 
|
5 | 5 | 
|
6 | 6 | 
|
7 | 7 |
|
8 |
| -This is a terminal-based application for interactively previews the stdin/stdout around the pipeline. |
| 8 | +This project is inspired by [akavel/up](https://github.com/akavel/up). |
| 9 | +`tp` is a terminal-based application for display the result of the command in real-time with each keystroke. |
9 | 10 |
|
10 |
| -## Installation |
11 |
| -``` |
12 |
| -$ git clone https://github.com/minefuto/tp.git |
13 |
| -$ cd tp |
14 |
| -$ make install |
15 |
| -``` |
| 11 | +It provides two displays. |
| 12 | +1. the input passed from last pipeline. |
| 13 | +2. the output of the command currently being typed. |
16 | 14 |
|
17 |
| -## Usage |
18 |
| -### 1. commandline mode |
19 |
| -<img src="https://github.com/minefuto/tp/blob/main/gif/mode1.gif"> |
| 15 | +You can consider the next commands while watching the input passed from pipeline. |
| 16 | +These will help you create complex commands including pipelines for get the ideal output with try and error. |
| 17 | +<br> |
| 18 | +Please type <kbd>Enter</kbd> when you completed to create command in `tp`. |
| 19 | +Then, `tp` returns the full result of the command as stdout/stderr. |
20 | 20 |
|
21 |
| -Add the following to shell's config file. |
22 |
| -`<key>`: Specify any key. |
23 |
| -**Bash(`.bashrc`)** |
| 21 | +<img src="https://github.com/minefuto/tp/blob/main/gif/tp.gif"> |
| 22 | + |
| 23 | +Also, `tp` can collaborate with the shell. |
| 24 | +By typing a shortcut key, you can start `tp` by capturing the command being typed into shell. |
| 25 | +And the command being typed into `tp` return to shell when type <kbd>Enter</kbd>. |
| 26 | + |
| 27 | +<img src="https://github.com/minefuto/tp/blob/main/gif/tp-shell.gif"> |
| 28 | + |
| 29 | +If you want to collaborate with the shell, please add the following to shell's config file. |
| 30 | +`<key>`: Specify any shortcut key. |
| 31 | + |
| 32 | +Bash |
24 | 33 | ```
|
25 | 34 | function transparent-pipe() {
|
26 |
| - READLINE_LINE=$(tp -c "${READLINE_LINE}|") |
| 35 | + READLINE_LINE=$(tp -c "${READLINE_LINE}") |
27 | 36 | READLINE_POINT=${#READLINE_LINE}
|
28 | 37 | }
|
29 | 38 | bind -x '"<key>": transparent-pipe'
|
30 | 39 | ```
|
31 |
| -**Zsh(`.zshrc`)** |
| 40 | +Zsh |
32 | 41 | ```
|
33 | 42 | function transparent-pipe() {
|
34 |
| - BUFFER="$(tp -c "${BUFFER}|")" |
| 43 | + BUFFER="$(tp -c "${BUFFER}")" |
35 | 44 | CURSOR=$#BUFFER
|
36 | 45 | }
|
37 | 46 | zle -N transparent-pipeline
|
38 | 47 | bindkey "<key>" transparent-pipe
|
39 | 48 | ```
|
40 |
| -**Fish(`config.fish`)** |
| 49 | +Fish |
41 | 50 | ```
|
42 | 51 | function transparent-pipe
|
43 | 52 | commandline | read -l buffer
|
44 |
| - commandline -r (tp -c "$buffer|") |
| 53 | + commandline -r (tp -c "$buffer") |
45 | 54 | commandline -f repaint
|
46 | 55 | end
|
47 | 56 | function fish_user_key_bindings
|
48 | 57 | bind "<key>" transparent-pipe
|
49 | 58 | end
|
50 | 59 | ```
|
| 60 | +<br> |
| 61 | + |
| 62 | +**Warning!!!** |
| 63 | +`tp` executes the command being typed with each keystroke. There is possibility to execute dangerous commands. |
| 64 | +So, create/delete operations(such as `mkdir`, `rm`) should not be typed because you might execute a careless command. |
| 65 | +`tp` is not designed for such operations. |
| 66 | + |
| 67 | +But I'm afraid of typo. |
| 68 | +`tp` provides a feature of prevent execution a specific commands. |
| 69 | +Please create block command list in `$TP_BLOCK_COMMAND` with `:` as delimiter. For example, |
| 70 | +``` |
| 71 | +export TP_BLOCK_COMMAND='mkdir:rmdir:rm:mv' |
| 72 | +``` |
| 73 | +Also, disable keystroke of redirection(`<`, `>`) in `tp` for the same reason. |
| 74 | + |
| 75 | +## Installation |
| 76 | +This steps will install to `$GOPATH/bin`. |
| 77 | +``` |
| 78 | +$ git clone https://github.com/minefuto/tp.git |
| 79 | +$ cd tp |
| 80 | +$ make install |
| 81 | +``` |
51 | 82 |
|
52 |
| -### 2. stdin/stdout mode |
53 |
| -<img src="https://github.com/minefuto/tp/blob/main/gif/mode2.gif"> |
| 83 | +## Keybindings |
| 84 | +| operation | key | |
| 85 | +|-------------------------------------------|------------------------------------------| |
| 86 | +| Move left(one char) | <kbd>←</kbd> / <kbd>Ctrl-B</kbd> | |
| 87 | +| Move right(one char) | <kbd>→</kbd> / <kbd>Ctrl-F</kbd> | |
| 88 | +| Move left(one word) | <kbd>Alt←</kbd> / <kbd>Alt-B</kbd> | |
| 89 | +| Move right(one word) | <kbd>Alt→</kbd> / <kbd>Alt-F</kbd> | |
| 90 | +| Move begin of the line | <kbd>Home</kbd> / <kbd>Ctrl-A</kbd> | |
| 91 | +| Move end of the line | <kbd>End</kbd> / <kbd>Ctrl-E</kbd> | |
| 92 | +| Delete one char before the cursor | <kbd>Backspace</kbd> / <kbd>Ctrl-H</kbd> | |
| 93 | +| Delete one char after the cursor | <kbd>Delete</kbd> / <kbd>Ctrl-D</kbd> | |
| 94 | +| Delete one word before the cursor | <kbd>Ctrl-W</kbd> | |
| 95 | +| Delete from the cursor to end of the line | <kbd>Ctrl-K</kbd> | |
| 96 | +| Delete all line | <kbd>Ctrl-U</kbd> | |
54 | 97 |
|
55 | 98 | ## Options
|
56 | 99 | ```
|
57 | 100 | > tp -h
|
58 | 101 | Usage of tp:
|
59 |
| - -c, --command Return commandline text (Please see the "1. commandline mode") |
| 102 | + -c, --command Return commandline text (for collaborate with the shell) |
60 | 103 | -h, --help Show help
|
61 | 104 | --horizontal Split the view horizontally
|
62 | 105 | -s, --shell string Specify the shell to use (default "$SHELL")
|
|
0 commit comments