
Quero definir uma variável com o nome do terminal e usar essa variável para abrir o terminal em tela cheia. Seria algo como:
if [ "$DESKTOP" = "gnome" ]; then
if command_exists gnome-terminal; then
terminal=$(gnome-terminal)
fi
elif [ "$DESKTOP" = "mate" ]; then
if command_exists mate-terminal; then
terminal=$(mate-terminal)
fi
fi
$terminal --working-directory="$HOME/code/" --window --full-screen &
Como faço para que isso funcione?
Responder1
simplesmente substitua $( )
por nada.
if [ "$DESKTOP" = "gnome" ]; then
if command_exists gnome-terminal; then
terminal=gnome-terminal
fi
elif [ "$DESKTOP" = "mate" ]; then
if command_exists mate-terminal; then
terminal=mate-terminal
fi
fi
$terminal --working-directory="$HOME/code/" --window --full-screen &
$( )
é usado para executar um comando e colar a saída, em uma variável ou na linha de comando.
o código acima pode não ser executado, se o terminal foo estiver indefinido, eu sugeriria
noterminal=true
if [ "$DESKTOP" = "gnome" ]; then
if command_exists gnome-terminal; then
gnome-terminal --working-directory="$HOME/code/" --window --full-screen &
noterminal=false
fi
elif [ "$DESKTOP" = "mate" ]; then
if command_exists mate-terminal; then
mate-terminal --working-directory="$HOME/code/" --window --full-screen &
noterminal=false
fi
fi
if $noterminal
then
echo unable to find terminal
## or other GUI alert system.
## or xterm as per mmmint sugestion
fi
Responder2
Pelo que eu sei, xterm
está disponível na maioria dos sistemas operacionais baseados em Linux.
Em qualquer caso, o terminal utilizado será encontrado na $TERM
variável.