diff options
| author | Alex Leferry 2 <alexherbo2@gmail.com> | 2020-08-31 12:39:23 +0200 |
|---|---|---|
| committer | Alex Leferry 2 <alexherbo2@gmail.com> | 2020-08-31 12:57:10 +0200 |
| commit | 2b47177f169268d31f763ba7814c188588320916 (patch) | |
| tree | 8af4dd613b357f387617c0129de60d0c7020728a /rc | |
| parent | 68ee78282769f51a5a3bf4b4d2c19dadf87bb71f (diff) | |
fifo: Add support for sending commands from the command-line
Diffstat (limited to 'rc')
| -rwxr-xr-x | rc/connect/commands/:fifo | 9 | ||||
| -rw-r--r-- | rc/modules/fifo.kak | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/rc/connect/commands/:fifo b/rc/connect/commands/:fifo index a9f0281..baf0137 100755 --- a/rc/connect/commands/:fifo +++ b/rc/connect/commands/:fifo @@ -4,4 +4,11 @@ mkfifo buffer.fifo trap 'rm buffer.fifo' EXIT :send edit! -fifo "$PWD/buffer.fifo" '*fifo*' -cat > buffer.fifo + +# Send to fifo buffer the output of the given command, +# or read from stdin if available. +if test -t 0; then + "$@" > buffer.fifo 2>&1 +else + cat > buffer.fifo +fi diff --git a/rc/modules/fifo.kak b/rc/modules/fifo.kak index 4a8158d..1d12834 100644 --- a/rc/modules/fifo.kak +++ b/rc/modules/fifo.kak @@ -2,6 +2,6 @@ provide-module connect-fifo %{ require-module connect define-command fifo -params 1.. -shell-completion -docstring 'Run command in a fifo buffer' %{ - $ %("$@" 2>&1 | :fifo) -- %arg{@} + $ %(:fifo "$@") -- %arg{@} } } |
