Linux: Inicie o tmux dentro do fbterm no login

2

Então, aqui está o que eu quero:

  • Em todos os tty login, fbterm é iniciado. Ele me dá uma resolução melhor do que o console linux, tem suporte a UTF-8 (tenho certeza que é totalmente minha culpa que o console Linux não tenha esses dois, mas eu não consigo fazer isso funcionar), e dá me acesso a mais janelas (10 por fbterm ).
  • Em cada janela fbterm , tmux está sendo executado. As sessões entre instâncias fbterm são completamente independentes, mas em cada janela fbterm , as tmux es compartilham o mesmo conjunto de janelas (mas mostram janelas diferentes).

Depois de algumas dificuldades, consegui alcançar isso - pretendo responder a essa questão eu mesmo. Você fez algo semelhante ou como você resolveria isso?

    
por Lucas Werkmeister 22.09.2013 / 13:53

3 respostas

2

Isso aqui é o que eu tenho agora, testei e está funcionando:

#!/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;

Coloque isso em algum arquivo, torne-o executável e execute-o em .profile (ou .bash_profile ). A intenção original era usar este script diretamente como seu shell de login, mas que atualmente é instável (funciona para minha conta, não funciona para uma nova conta de teste fictícia).

    
por 22.09.2013 / 23:14
0

Não tenho certeza se é a resposta que você está procurando, mas tenho me esforçado para fazer com que o fbterm e o tmux iniciem automaticamente sem entrar no caminho um do outro. Isso no .profile fez o truque para mim:

if [[ ! $TERM =~ screen ]]; then
   SHELL=tmux fbterm
fi
    
por 18.03.2014 / 00:08
0

Eu uso o seguinte no meu .bashrc , que, acredito, alcança quase a mesma funcionalidade:

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

Isto irá abrir o fbterm (se possível) e depois o tmux em qualquer novo shell interativo. Ele será anexado a uma sessão do tmux com o nome especificado, se existir, ou criará uma, se não.

    
por 15.10.2017 / 00:38