- Notifications
You must be signed in to change notification settings - Fork13
A tool to interactively write shell pipelines.
License
elkowar/pipr
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Pipr is a commandline pipe-building tool, written in Rust!
Pipr can automatically evaluate the pipeline you're editing in the background,showing you the results as you go.This makes writing complexsed
andawk
chains a lot easier,as you'll immediately see what they do.
Because thiscould be dangerous,(imagine typingrm ./*.txt
to delete all text files,but it already being executed atrm ./*
, deleting all files in your working directory),Pipr usesbubblewrap to execute your commandin an isolated, read-only environment, making it safe to use. I wont give any guarantees,but youshould be good :D.
To allow for even more efficiency,Pipr features a command history and a bookmark system,allowing you to quickly go back to previously worked on pipelinesor look at how you did something before.
It also features a snippet-system, allowing you to define custom snippetsthat can be inserted with the press of a button.These can be used to insert common stuff likesed -r 's///g'
,even allowing you to specify where the cursor should be placed after inserting the snippet.
You can even look up documentation and help of your commands on the fly.Simply hover your cursor over the desired command and pressF5
.You can then choose between different documentation-options to look at.You can add your own options (for exampletldr) in the config filein the[help_viewers]
section.
If none of the listed installation-options are available to you,you can simply use the static binary provided on thereleases page.Thisshould work on most unix-based systems.
Pipr is available on the AUR, so you can simply install it using your favourite AUR-helper:
$ yay -S pipr-git
or for a binary:
$ yay -S pipr-bin
If you have a Rust-setup and havecargo
installed, you can install pipr using cargo:
$ cargo install pipr
Just startpipr
!
Help is available inpipr
by pressing F1.
You can evaluate a command by pressing enter.
There is also theautoeval mode: Enabled by simply pressingF2
, this mode runs your command after every keypress.
The textfield works like you would expect, supportingCtrl+A
,Ctrl+E
to jump to the start / end of the line,Ctrl+U
to clear the whole text-field, andAlt+Enter
to insert a newline.
Pipr keeps a history of your commands, through which you can cycle usingCtrl+P
andCtrl+N
.You can also look at the whole History by pressingF4
.In autoeval mode, you're not pressing Enter that often, so pipr might loose some parts of history.If you want to avoid that, you can enter "paranoid history mode" by pressingF3
,in which Pipr will save any command that successfully runs into the history.
If youreally like a command you worked on, you can alsobookmark it by pressingCtrl+S
.You can look through all bookmarked commands by pressingCtrl+B
.
A lot of times, you'll type the same things over and over again, for exampleawk '{print $...}'
,sed 's/.../.../g'
.To make this more efficient, pipr supportssnippets: By pressingCtrl+V
,you can open a menu of all your configured snippets. Just choose one by pressing it's respective key,and it will be inserted at your cursor, placing your cursor where it is supposed to.You can configure your own snippets in the config file!
Ever worked on a long pipeline, and suddenly forgot that one flag youreally need?No problem, just hover your cursor over the command and pressF5
.This will open a menu, giving you the option to open the commands help-output or man-page.You can also configure more help-viewers in the config-file.
If you need to inspect your commands output a bit more deeply,pipr's built-in output window might not be sufficient.That's not a problem, because you can open the output in a pager of your liking.Simply pressF6
and choose your outputviewer.These are also configurable, so you can add more specific things likefx.
If your command uses the output of a slow command, or maybe the result of a http-request,rerunning that command with every keypress might not be a good idea.For this, you can hover over any|
symbol and pressF7
to cache everything up to that pipe.This way, it will not be rerun unless you change it.
(This is especially important if you're using an external API with rate-limiting!)
Well,... pipr has it. Never forget your filenames ever again!
Pipr's configuration is stored in~/.config/pipr/pipr.toml
.You can add your own output-viewers, help-viewers, snippets and much more here.Also, configure things like enabling autoeval-mode by default.
If you accidentally removed something from the config, fear not:pipr can print out it's well-commented default config if you pass it the--config-reference
flag.
the finish hook (configured in the config-file) is a command that will be executed after you close pipr,and will get the finished bash command line piped into stdin.This can be used to pipe your work into xclip, storing it in your clipboard,thus making it possible to quickly paste it into the terminal.
In theshell_integration/
folder in this repository you'll find some scripts for different interactive shells.These allow you to call pipr from the terminal with a simple keypress,inserting your current line-buffer into pipr.If you're using fish, it will even put the final command back into your terminal's linebuffer after closing pipr.
To use these, simply put the lines from the respective file into your.bashrc
orconfig.fish
file.
Keymappings
Fish: Ctrl+Alt+a
Bash: Alt+a
Pipr usesbubblewrapto execute your command in an isolated environment,preventing most (but maybe not all, I won't give you any guarantees) dangerslike accidentally deleting something while you're typing a command.
This means that you'll need to have bubblewrap somewhere on yourPATH
,or you'll have to use the unsafe-mode by passing theno-isolation
flag.
About
A tool to interactively write shell pipelines.