Linux: Запустите tmux внутри fbterm при входе в систему

1721
Lucas Werkmeister

Итак, вот что я хочу:

  • При каждом входе в tty fbtermзапускается. Он дает мне лучшее разрешение, чем консоль linux, имеет работающую поддержку UTF-8 (я уверен, что это полностью моя вина, что консоль linux не имеет этих двух, но я не могу заставить ее работать), и дает мне доступ к большему количеству окон (10 на fbterm).
  • В каждом fbtermокне tmuxработает. Сеансы между fbtermэкземплярами полностью независимы, но в каждом fbtermокне они используют tmuxодин и тот же набор окон (но показывают разные окна).

После некоторой борьбы мне удалось этого добиться - я собираюсь ответить на этот вопрос сам. Вы сделали что-то подобное, или как бы вы решили это?

2

3 ответа на вопрос

2
Lucas Werkmeister

This here is what I have now, I tested it and it's working:

#!/bin/sh if [[ -n "$TMUX" ]]; then echo "CRITICAL - ALREADY INSIDE TMUX!" echo "Dropping you into /bin/sh..." /bin/sh -i echo "Exiting with /bin/sh exit code..." exit $? fi SESSION="$(whoami)-$(basename $(tty))"; # Start tmux server if it isn't already running echo "Starting tmux server..." /usr/bin/tmux start-server echo "tmux server started." # Create the session if it doesn't exist echo "Checking for tty session..." if /usr/bin/tmux has-session -t "$SESSION" 2> /dev/null; then echo "tty session already present, will spawn new window later." else echo "Creating tty session..." /usr/bin/tmux new-session -d -s "$SESSION" -n "$SESSION-dummywindow" /bin/bash echo "tty session created." fi # Create a new session that shares the windows of the existing (or new) session echo "Starting fbterm and tmux..." ( sleep 1; /usr/bin/tmux kill-window -t "$SESSION-dummywindow" ) & /usr/bin/fbterm -- /usr/bin/tmux new-session -t "$SESSION" \; new-window /bin/bash; 

Put this into some file, make it executable, then run it from your .profile (or .bash_profile). The original intention was to directly use this script as your login shell, but that is currently unstable (works for my account, doesn't work for a newly-created dummy test account).

Если это правильное решение, пометьте его как таковое. Daniel B 10 лет назад 0
0
MajorBriggs

Not sure it's the answer you're looking for but I've been struggling myself to get fbterm and tmux to autostart without getting in each other's way. This in .profile did the trick for me:

if [[ ! $TERM =~ screen ]]; then SHELL=tmux fbterm fi 
0
Ryan Lue

Я использую следующее в моем .bashrc, которое, я считаю, достигает почти такой же функциональности:

if [ -z "$SSH_CONNECTION" ]; then # if in virtual terminal, start fbterm if [[ "$(tty)" =~ /dev/tty ]] && type fbterm > /dev/null 2>&1; then fbterm # otherwise, start/attach to tmux elif [ -z "$TMUX" ] && type tmux >/dev/null 2>&1; then tmux new -As "$(basename $(tty))" fi fi 

Это откроет fbterm (если возможно), а затем tmux в любой новой интерактивной оболочке. Он присоединится к сеансу tmux с указанным именем, если оно существует, или создаст его, если нет.

Похожие вопросы