https://github.com/denisidoro/abra
Easily share data between terminal windows!
https://github.com/denisidoro/abra
cli rust socket unix
Last synced: 7 months ago
JSON representation
Easily share data between terminal windows!
- Host: GitHub
- URL: https://github.com/denisidoro/abra
- Owner: denisidoro
- License: apache-2.0
- Created: 2021-01-04T18:01:45.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-15T11:37:49.000Z (over 4 years ago)
- Last Synced: 2025-03-18T08:53:27.517Z (7 months ago)
- Topics: cli, rust, socket, unix
- Language: Rust
- Homepage:
- Size: 53.7 KB
- Stars: 26
- Watchers: 2
- Forks: 1
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# abra 
A tool that makes data sharing between terminal windows easy.**abra** can be used for displaying info about the current working directory, for splitting stdout and stderr and much more.
In the example below, whenever I `cd` into a different folder, another terminal window lists the files inside it.

Table of contents
-----------------* [Installation](#installation)
* [Basic concepts](#basic-concepts)
* [Common use cases](#common-use-cases)
* [Advantages over named pipes](#advantages-over-named-pipes)
* [Forcing colorized output](#forcing-colorized-output)
* [Similar tools](#similar-tools)
* [Etymology](#etymology)Installation
------------The recommended way to install **abra** is by running:
```sh
cargo install kadabra
```You can also run:
```sh
brew install denisidoro/tools/abra
```If these package managers aren't available, you can download a pre-compiled binary [here](https://github.com/denisidoro/abra/releases/latest) and extract it to your `$PATH`.
Basic concepts
-----------------
- **abra** is built over Unix sockets
- it can publish and subscribe to channels, manipulating text as necessary
- no terminal multiplexers are necessaryCommon use cases
-----------------Some **abra** calls are quite verbose, so the use of [aliases](https://github.com/denisidoro/abra/blob/master/shell/aliases.bash) is recommended.
### File tree sidebar
Since this is a very common use case, **abra** provides a hook for you.
If you call the following...
```sh
eval "$(abra hook bash)" # If you use bash, add this to ~/.bashrc
eval "$(abra hook zsh)" # If you use zsh, add this to ~/.zshrc
```Then you can open a new terminal window and call `abra rx --channel pwd --cmd 'ls {}'`.
Whenever you `cd` into a directory, the sidebar will reflect the changes.
### Split stdout and stderr into different windows
Let's say that you want to run some tests but errors should appear in a different window.
You can use anonymous pipes with **abra** for that purpose:

The commands are:
```sh
abra rx --channel test_out # window 1
abra rx --channel test_err # window 2
cargo test > >(abra tx --channel test_out) 2> >(abra tx --channel test_err) # window 3
```### Filter some output lines
Let's say you want to see the contents of a file in a window but show only the lines that contain "foo" in another window:
```sh
abra rx --channel filter --cmd 'echo "{}" | grep foo' # window 1
cat myfile.txt |& tee >(abra tx --channel filter) # window 2
```Forcing colorized output
-------------Some CLIs will detect that they are being piped and will hide color information by default.
To circumvent this, each CLI may offer different parameters: `--color=always` and `export COLORTERM=truecolor` are some examples.
In some cases, you need to trick an application into thinking its stdout is a terminal, not a pipe. For these cases you can call `abra faketty --cmd ''`.
Advantages over named pipes
-------------In theory, you could run the following to achieve similar results:
```sh
mkfifo tmp
tail -f tmp
echo foo > tmp # in another window
```That said:
- with **abra** you don't need to worry about creating/removing named pipes
- `echo foo > tmp` is blocking in case `tmp` isn't open for reading
- `abra tx` will terminate immediately if there's no `abra rx` process
- you can have many `abra rx` windows reacting to the same `abra tx` call
- **abra** is cross-platform
- to correctly create temporary named pipes you need to write platform-specific codeSimilar tools
-------------- [tmux-sidebar](https://github.com/tmux-plugins/tmux-sidebar)
Etymology
---------[Abra](https://bulbapedia.bulbagarden.net/wiki/Abra_(Pok%C3%A9mon)) is a [Pokémon](https://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9mon) who is able to [teleport](https://bulbapedia.bulbagarden.net/wiki/Teleport_(move)).