Skip to content

Commit ad514b5

Browse files
committed
update README.md
1 parent d880070 commit ad514b5

File tree

5 files changed

+65
-22
lines changed

5 files changed

+65
-22
lines changed

README.md

Lines changed: 65 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,105 @@
1-
# Transparent Pipe : A terminal-based pipeline command
1+
# Transparent Pipe(tp)
22
[![Go Report Card](https://goreportcard.com/badge/github.com/minefuto/tp)](https://goreportcard.com/report/github.com/minefuto/tp)
33
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/minefuto/tp/build)
44
![GitHub release (latest by date)](https://img.shields.io/github/v/release/minefuto/tp)
55
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/minefuto/tp)
66
![GitHub](https://img.shields.io/github/license/minefuto/tp)
77

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.
910

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.
1614

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.
2020

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
2433
```
2534
function transparent-pipe() {
26-
READLINE_LINE=$(tp -c "${READLINE_LINE}|")
35+
READLINE_LINE=$(tp -c "${READLINE_LINE}")
2736
READLINE_POINT=${#READLINE_LINE}
2837
}
2938
bind -x '"<key>": transparent-pipe'
3039
```
31-
**Zsh(`.zshrc`)**
40+
Zsh
3241
```
3342
function transparent-pipe() {
34-
BUFFER="$(tp -c "${BUFFER}|")"
43+
BUFFER="$(tp -c "${BUFFER}")"
3544
CURSOR=$#BUFFER
3645
}
3746
zle -N transparent-pipeline
3847
bindkey "<key>" transparent-pipe
3948
```
40-
**Fish(`config.fish`)**
49+
Fish
4150
```
4251
function transparent-pipe
4352
commandline | read -l buffer
44-
commandline -r (tp -c "$buffer|")
53+
commandline -r (tp -c "$buffer")
4554
commandline -f repaint
4655
end
4756
function fish_user_key_bindings
4857
bind "<key>" transparent-pipe
4958
end
5059
```
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+
```
5182

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> |
5497

5598
## Options
5699
```
57100
> tp -h
58101
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)
60103
-h, --help Show help
61104
--horizontal Split the view horizontally
62105
-s, --shell string Specify the shell to use (default "$SHELL")

gif/mode1.gif

-1010 KB
Binary file not shown.

gif/mode2.gif

-248 KB
Binary file not shown.

gif/tp-shell.gif

2.16 MB
Loading

gif/tp.gif

1.91 MB
Loading

0 commit comments

Comments
 (0)