44

I'm installing liquidprompt and in the documentation they ask you to add [[ $- = *i* ]] && source ~/liquidprompt/liquidprompt in your .bashrc .

I am trying to understand the first part of the line but it's hard for a noob in bash like me. If anyone has a nice doc or the answer...

1

2 Answers 2

72

$- contains the current shell options.

In [[ ... ]], the right hand side of a = is interpreted as a pattern if not quoted. Therefore, *i* means i possibly preceded or followed by anything.

In other words, it checks wheter the i option is present, i.e. whether the current shell is interactive.

1
  • 4
    Approved by the liquidprompt maintainer himself (who wrote that instruction in the manual).
    – dolmen
    Commented Dec 12, 2015 at 22:09
16

It is checking whether the options for the shell $- contains an i in them. The i is for interactive

From the Bash man page:

An interactive shell is one started without non-option arguments and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.

Also relevant

1
  • 2
    Approved by the liquidprompt maintainer himself (who wrote that instruction in the manual).
    – dolmen
    Commented Dec 12, 2015 at 22:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.