Skip to content
Discussion options

You must be logged in to vote

ble.sh manages stdout/stderr of the executed commands separately from stdout/stderr of the line editor itself. The file descriptors for stdout/stderr of the executed commands are stored in the shell variables _ble_util_fd_cmd_stdout and _ble_util_fd_cmd_stderr. So, technically, you can redirect these file descriptors in preexec.

For example, if you want to redirect stdout/stderr when the executed command is ls, you can naively write it in the following way.

preexec() {
  exec {_ble_util_fd_cmd_stdout}>&-
  exec {_ble_util_fd_cmd_stderr}>&-
  if [[ $1 == 'ls' ]]; then
    builtin eval -- "exec $_ble_util_fd_cmd_stdout> >(cat -n) $_ble_util_fd_cmd_stderr>&$_ble_util_fd_cmd_stdout"
  else
    

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@akinomyoga
Comment options

Answer selected by darukutsu
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants