In sqsh, can an alias do a reconnet and change the prompt? I want to change color for production

197 Views Asked by At

Using sqsh, in my .sqshrc, I can have an alias to connect to a production server, and an alias to change my colors:

\alias prod='\reconnect -S MY_PROD_DS ...'
\alias pc='\set prompt="{0;47;34} [$histnum] ${DSQUERY}.${database}.${lineno}> "'

How can I have one alias that does both?

1

There are 1 best solutions below

0
On BEST ANSWER

I don't think it is possible to have 2 or more commands in one alias. The best way to specify a server dependent prompt is to set it in the session file that is being evaluated just before setting up a new connection to the server. In your .sqshrc file you can specify the session file and prompt definition, for example:

    \set session='$HOME/.sqsh_session'
    \set text_color='{0}'
    \set prompt='$prompt_color[$histnum]$DSQUERY.$username.$database.$lineno>$text_color '

In this session file you then can do something like:

    \if [ "$DSQUERY" = "MY_PROD_DS" ]
      \set prompt_color='{0;31;47}'
    \else
      \set prompt_color='{0;34;47}'
    \fi

When you connect or reconnect to the MY_PROD_DS server you get a red on white color prompt, otherwise a blue on white prompt.