2

Does anyone know if there is a way reproducing the same behaviour many text editors provide for colour-highlighting the syntax operators such as brackets or curly brackets. It would be very useful for complex one-liners in the terminal.

Example of the functionality I am talking about (from VIM).

Example

10
  • Sorry I don't understand what do you mean... Commented Nov 28, 2012 at 11:36
  • I mean if it's complicated, it should be in a script editor, i.e VIM
    – daisy
    Commented Nov 28, 2012 at 11:38
  • Thanks, I see what you mean now and you are right. Nevertheless it is still very useful. Sometimes I am debugging some R code interactively, I need to paste some of the complex lines in the R-console and change some parameters. As R uses .inputrc I thought that I could make bash do these high-lightning and R could inherit. Commented Nov 28, 2012 at 12:19
  • You can run a terminal in Emacs. Its functions to find matching parentheses are available there. I do not know whether the same is possible in VIM.
    – choroba
    Commented Nov 28, 2012 at 12:37
  • 2
    I believe the term is parenthesis (or bracket) matching. For bash, you could look at blink-matching-paren: Bash readline blinking matching parentheses
    – Zorawar
    Commented Nov 28, 2012 at 14:35

1 Answer 1

6

When writing complex one liners in bash, it is handy to use readline's edit-and-execute-command (bound to C-xC-e by default in emacs mode). Hitting C-xC-e opens current commandline in the editor of your choice with all its fancy features. After saving it, bash will execute the contents as shell commands.

Alternatively, issue bash's builtin fc to open last command in the editor.

1
  • Perfect. Do you have an idea if I could get the same behaviour within the R-console? I know that R uses readline. EDIT: @Zorawar 's link in the comment above solves this issue by adding set blink-matching-paren on in my .inputrc file Commented Nov 28, 2012 at 15:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .