Pergunta

Not sure whether obfuscated, machine-code or something else. Please, let me know what the part is for and how to read it. The part is from the file.

###############################################################################
# Set prompt based on EUID
################################################################################
if (( EUID == 0 )); then
    PROMPT=$'%{\e[01;31m%}%n@%m%{\e[0m%}[%{\e[01;34m%}%3~%{\e[0;m%}]$(pc_scm_f)%# '
else
    PROMPT=$'%{\e[01;32m%}%n@%m%{\e[0m%}[%{\e[01;34m%}%3~%{\e[0;m%}]$(pc_scm_f)%% '
fi

could someone break it a bit more into parts?

  1. What does the conditional EUID == 0 do?
  2. I get an error about pc_scm_f, using OBSD, is it some sort of value in other OS?
  3. the \e starts some sort of logical part, what do the rest do?
Foi útil?

Solução

Looks like ANSI escape sequences to me.

Outras dicas

I found this link which seems to contain the whole thing in proper context. Also tells me Ferruccio is right: It's an ANSI escape string, used to change the style of the command-prompt. \e starts the escape codes, the rest is the code itself. Used to be very popular in the old DOS time, especially with a game called NetHack. It's just pretty-print for your console.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top