[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: redirection back to tty problem
From: |
Alex fxmbsw7 Ratchev |
Subject: |
Re: redirection back to tty problem |
Date: |
Sun, 27 Feb 2022 13:14:54 +0100 |
well i forwarded your text to him
in the end ppl in #bash helped me get it up, the my script
cat cmdhelp
#!/usr/bin/env -S bash
# for to be sourced in .bashrc or such
i=${SRANDOM:-$RANDOM}
t=/tmp/.$i o2=$t.2
trap '
if [[ $BASH_COMMAND == *--help* ]] ; then
exec {fd1}>&1 {fd2}>&2 >"$o2" 2>&1
cmd=$BASH_COMMAND
printf %s\\n\\n "$cmd"
fi' debug
PROMPT_COMMAND='
if [[ $cmd ]] ; then
exec >&$fd1 2>&$fd2
vim "$o2"
exec {fd1}>&- {fd2}>&-
cmd=
fi
'$PROMPT_COMMAND
On Sun, Feb 27, 2022 at 1:02 PM Chris Elvidge <celvidge001@gmail.com> wrote:
>
> On 27/02/2022 10:31, Alex fxmbsw7 Ratchev wrote:
> > i made by request of an user a script that intercepts whenever a --help
cmd
> > is given, to open that output in vim ( nvim ) i guess to study, good
thing
> >
>
> Try: (cp is just here to test command)
>
> cp --help | view -c 'set ft=man nomod' -c 'set noeb vb t_vb=' -c 'map q
> <Esc>:q!<cr>' -c 'map i <nop>' -
>
> view is read-only, q to exit help.
> gview to open help in GUI version.
>
>
>
>
> --
> Chris Elvidge
> England
>