Pergunta

I have a chunk of code in my .bashrc, everytime one runs the shell (I usually use konsole) a switch case appears giving options of which branch or trunk to use. Example:

1) V0230
2) V0300
3) Dev

Enter Option: __

$PROJECT_HOME and others variables are set upon the choise made.

The annoying thing in this is that it appears everytime I open a new tab the same screen is printed. But yet I want to open a new konsole and use a different branch, so, simple export a variabe can not be the solution

Must have a way to run this code only when a konsole new screen is open. Maybe making alias konsole=konsole --run <desired-function>. The konsole's documentation doesn't give a help, theres not even a man konsole just konsole --help.

Foi útil?

Solução

Just create an alias:

$ alias konsole_select_branch='SELECT_BRANCH=true konsole'

and in your .bashrc:

if [ -n "$SELECT_BRANCH" ]
then
   # select branch
fi

and use konsole or konsole_select_branch whether you want to choose a branch or just open a tab or window.

Outras dicas

You could put a script in .bashrc which partly overwrite .bashrc; the zsh autocompletion facility does something similar, e.g. maybe do something like

 if [ -f $HOME/.somebashthing; ]; then
    . $HOME/.somebashthing
 else
    read SOMETHING
    echo SOMEVAR=$SOMETHING > $HOME/.somebashthing
 fi

This is only a sketch; it is up to you to fill the details.

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