, я хочу установить переменную с именем терминала и использовать эту переменную для открытия терминала в полноэкранном режиме. Это будет примерно так:
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 &
Как мне заставить это работать?
просто замените $( )
на ничто.
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 &
$( )
используется для выполнения команды и вставки вывода либо в переменную, либо в командную строку.
приведенный выше код может не выполняться, если терминал foo не определен, я бы предложил
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
Насколько мне известно, xterm
доступен в большинстве ОС на базе Linux.
В любом случае используемый терминал будет найден в переменной $TERM
.