Hace 12 años

Hace 12 años

Acabo de instalar tmux en Ubuntu 10.04 e intenté reasignar la clave del prefijo C-acreando el archivo ~/.tmux.confcon estas líneas:

set-option -g prefix C-a
unbind-key C-b

Al iniciar tmux, tanto regularmente como con -f ~/.tmux.conf, el prefijo es efectivamente el mismo predeterminadoC-b

No hay errores ni advertencias de ningún tipo.

¿Alguna idea de qué pasa con la carga de la configuración?

Respuesta1

El archivo ~/.tmux.conf se carga cuando se inicia el servidor tmux por primera vez. Entonces, si hay sesiones tmux existentes, iniciar una nueva sesión tmuxno da como resultado la recarga del archivo .tmux.conf. Intente reiniciar el servidor tmux: use el comando tmux list-sessionspara ver si hay sesiones existentes. Salga de ellos (por ejemplo tmux attach, cierre todas las ventanas y salga). Una vez que hayan finalizado todas las sesiones, inténtelo tmuxde nuevo. Esta vez la nueva vinculación debería funcionar.

Respuesta2

Para recargar su ~/.tmux.conf sin cerrar su sesión, simplemente puede hacer:

<prefix> :source-file /absolute/path/to/your/.tmux.conf

donde <prefix>está <C-b>por defecto.

Respuesta3

ejecuta dentro de tu sesión tmux:

tmux source-file /absolute/path/to/your/.tmux.conf

Respuesta4

Hace 12 años

Ahéroedejo uncomentario.

Funciona para mí™. Intente ejecutar strace -s9999 -f -o tmux.strace tmux -c truey publicar el resultado de grep -C5 'tmux\.conf' tmux.strace. – Gilles 'SO- deja de ser malvado' 14 de septiembre de 2010 a las 20:24

Una clase magistral de eufemismo

Sin fanfarronadas dejaron caer una sola frase en un comentario que debería haber sido, no sólouna respuestapero,la respuesta. No solola respuestaa esta pregunta, perola respuesta de referenciaa toda una clase de preguntas.

Rompiéndolo

¿Que strace -s9999 -f -o tmux.strace tmux -c truesignifica?

Es como 2 comandos en 1. El comando principal tiene tmuxun "prefijo"/"contenedor" llamado strace. Esto es muy similar a ejecutar time dfpara medir cuánto tiempo lleva ejecutar el dfcomando.

strace -s9999 -f -o tmux.strace

$ man strace | grep -A1 ^NAME
NAME
       strace - trace system calls and signals

$ man strace | grep -EA10 '^ *DESCRIPTION($| )'
DESCRIPTION
       In the simplest case strace runs the specified command until it  exits.   It
       intercepts  and  records  the system calls which are called by a process and
       the signals which are received by a process.  The name of each system  call,
       its  arguments  and its return value are printed on standard error or to the
       file specified with the -o option.

       strace is a useful diagnostic, instructional, and  debugging  tool.   System
       administrators,  diagnosticians and trouble-shooters will find it invaluable
       for solving problems with programs for  which  the  source  is  not  readily
       available  since  they  do not need to be recompiled in order to trace them.

$ man strace | grep -EA4 '^ *-s($| )'
       -s strsize
       --string-limit=strsize
                   Specify the maximum string size to print (the  default  is  32).
                   Note  that  filenames  are not considered strings and are always
                   printed in full.

$ man strace | grep -EA6 '^ *-f($| )'
       -f
       --follow-forks
                   Trace child processes as they are created  by  currently  traced
                   processes as a result of the fork(2), vfork(2) and clone(2) sys‐
                   tem calls.  Note that -p PID  -f  will  attach  all  threads  of
                   process  PID  if  it  is  multi-threaded,  not  only thread with
                   thread_id = PID.

$ man strace | grep -EA8 '^ *-o($| )'
       -o filename
       --output=filename
                   Write the trace output to  the  file  filename  rather  than  to
                   stderr.   filename.pid  form  is used if -ff option is supplied.
                   If the argument begins with '|' or '!', the rest of the argument
                   is  treated as a command and all output is piped to it.  This is
                   convenient for piping the debugging output to a program  without
                   affecting  the redirections of executed programs.  The latter is
                   not compatible with -ff option currently.

tmux -c true

$ man tmux | grep -EA4 '^ *-c($| [^ ]*$)'
     -c shell-command
                   Execute shell-command using the default shell.  If necessary,
                   the tmux server will be started to retrieve the default-shell
                   option.  This option is for compatibility with sh(1) when tmux
                   is used as a login shell.

$ man true | grep -A1 ^NAME
NAME
       true - do nothing, successfully

Por qué...

¿Usar -ccon tmux?

Dado que realmente solo nos preocupamos por el proceso de inicio de tmux, no necesitamos usarlo de forma interactiva. Por lo tanto, le indicaremos que ejecute un comando en lugar de nuestro shell interactivo normal.

¿Usar truecomo comando tmux?

Porque sale muy rápidamente y mantendrá nuestro registro breve.

¿Usar -o tmux.stracecon strace?

Es solo un archivo para almacenar la salida. Nombrar las cosas es difícil. No era importante hacer coincidir el nombre base o la extensión con nada más.

¿Usar -fcon strace?

Asumiré que leíste el extracto de la página de manual y noredundar. Cualquier aplicación razonablemente compleja creará procesos secundarios. Dado que tmuxes magníficamente complejo, definitivamente queremos analizarlos también.

¿Usar -s9999con strace?

Dado que estamos escribiendo la salida en un archivo, no necesitamos una línea truncada para que se ajuste al ancho de nuestra terminal. Ponlo grande. Ocúpate de mostrarlo más tarde si es un problema.

Por quécualquiera de esta?

si porcualquier, te refieres a escribir esta respuesta larga...

  1. Porque capacito equipos de ingeniería y les indicaré esta respuesta.
  2. Porque Gil...
    • es un maldito héroe
    • tuvo 0 votos positivos en su comentario durante más de 10 años
    • ha pasado desapercibido durante demasiado tiempo y me niego a que continúe

Si no ve por qué este proceso esEl caminopara responder una pregunta como "¿Alguna idea de qué pasa con la carga de la configuración?" entonces te recomendaría elProblema XY

No es solointerrogadoresque caen en el Problema XY. ÉlextremadamenteEs común que las respuestas ~ cometan este error ~ hagan esto también. En este caso, muchas respuestas a esta pregunta instruyen al lector cómo cargar/recargar un archivo de configuración una vez iniciado el proceso. Eso sugiere ignorar el hecho de que el proceso no carga el archivo como debería.

Si has llegado hasta aquí, lo que quiero que recuerdes es que solo está bien ignorar un fracaso si:

  • Pasar un bloqueador para poder eliminarte como bloqueador para los demás.
  • Volveré para solucionar el problema correctamente más tarde.

La comida para llevar

Muchos problemas se pueden resumir en "¿Qué pasa con la carga del archivo?". Esa pregunta debería provocar un sentimiento arácnido en forma de "¿Está intentando cargar el archivo? ¿Qué sucede cuando lo intenta?"

Puedes/debes[?] usar stracepara resolver cualquier cosa que pueda cuestionarse como:

  • ¿Qué intenta hacer este proceso?
  • Qué esélexperimenta cuando intenta hacer eso [cosa que está tratando de hacer]?

A menudo, esno es un fracaso del procesohacer algo, peroun fallo del usuarioesperando que el proceso haga algo. Y el proceso experimenta muchas cosas de las que el usuario no está informado.

Basta ya de pontificación abstracta. Consideremos un ejemplo:

$ tmux kill-server; rm tmux.strace; strace -s9999 -f -o tmux.strace tmux -c true
no server running on /tmp/tmux-1000/default

$ ls -lh tmux*
-rw-r--r-- 1 bruno bruno  21K Jun 11 10:58 tmux-client-18358.log
-rw-r--r-- 1 bruno bruno 324M Jun 11 10:58 tmux-server-18360.log
-rw-r--r-- 1 bruno bruno 342K Jun 11 13:48 tmux.strace

$ grep 'tmux\.conf' tmux.strace
521744 readlink("/etc/tmux.conf", 0x7ffe2c0446d0, 1023) = -1 ENOENT (No such file or directory)
521744 readlink("/home/bruno/.tmux.conf", 0x7ffe2c0446d0, 1023) = -1 ENOENT (No such file or directory)
521744 readlink("/home/bruno/.config/tmux/tmux.conf", 0x7ffe2c0446d0, 1023) = -1 ENOENT (No such file or directory)

$ ls -lA /home/bruno/.config/tmux
-rw-r--r-- 1 bruno bruno 307 Jun 10 20:29 tmux.config

¿Lo ves? Mire el resultado de los últimos 2 comandos. Tal vez sería útil si te mostrara cómo lo soluciono.

$ mv ~/.config/tmux/tmux.config \
    ~/.config/tmux/tmux.conf

$ tmux kill-server; rm tmux.strace; strace -s9999 -f -o tmux.strace tmux -c true
no server running on /tmp/tmux-1000/default

$ grep -A2 '\.config/tmux/tmux\.conf' tmux.strace
527872 openat(AT_FDCWD, "/home/bruno/.config/tmux/tmux.conf", O_RDONLY) = 8
527872 newfstatat(8, "", {st_mode=S_IFREG|0644, st_size=307, ...}, AT_EMPTY_PATH) = 0
527872 read(8, "set -sg escape-time 0\nset -g mode-keys vi\n\n# remap prefix from 'C-b' to 'C-f'\nset-option -g prefix C-f\nunbind-key C-b\nbind-key C-f send-prefix\n\n# split panes using | and -\nbind | split-window -h\nbind - split-window -v\n# bind \"\33OA\" # scroll natural up\n# bind \"\33OB\" # scroll natural down\nunbind '\"'\nunbind %\n\n", 4096) = 307

Nota: Esa última línea es el contenido completo de mi ~/.config/tmux/tmux.confarchivo (anteriormente mal llamado).

información relacionada