toi
(pronounced "toi", meaning "question" in Japanese) is a command-line tool designed to add an interactive confirmation step to Unix-style pipelines. It allows users to inspect the output of a command before passing it to the next command in the pipeline.
The name toi
comes from the Japanese word "問い" (toi), which means "question" or "inquiry". This reflects the tool's primary function of providing a confirmation prompt.
- Displays input content for review
- Interactive confirmation prompt
- Customizable timeout
- Default yes/no options
- Custom prompt messages
- Works seamlessly in complex pipelines
You can install toi
directly using Go:
go install github.com/nwiizo/toi@latest
Make sure your $GOPATH/bin
is in your PATH
to run the installed binary.
You can download pre-built binaries for your platform from the releases page.
- Download the appropriate binary for your operating system and architecture.
- Extract the archive:
tar -xzvf toi_<version>_<os>_<arch>.tar.gz
- Move the binary to a directory in your PATH:
sudo mv toi /usr/local/bin/
If you prefer to build from source:
-
Clone the repository:
git clone https://github.com/nwiizo/toi.git cd toi
-
Build the binary:
go build -o toi
-
(Optional) Move the binary to a directory in your PATH:
sudo mv toi /usr/local/bin/
Basic syntax:
command1 | toi [flags] | command2
-t, --timeout int
: Set a timeout in seconds (0 for no timeout)-y, --yes
: Default to yes if no input is provided-n, --no
: Default to no if no input is provided-p, --prompt string
: Set a custom prompt message
-
Basic usage:
ls | toi | wc -l
This will display the output of
ls
, prompt for confirmation, and if approved, count the number of lines. -
Using default yes:
echo "Hello, World!" | toi -y | tr '[:lower:]' '[:upper:]'
This will convert the input to uppercase without prompting, due to the
-y
flag. -
With timeout:
cat /etc/passwd | toi -t 5 | grep root
This sets a 5-second timeout for the confirmation prompt.
-
Custom prompt:
ps aux | toi -p "Do you want to see the process list? (y/n): " | awk '{print $2, $11}'
This uses a custom prompt message before displaying the process list.
-
Complex pipeline:
find . -type f | toi | xargs -I {} sh -c 'echo "Processing: {}"; wc -l {}'
This finds all files in the current directory, confirms, then counts lines in each file.