Tmux: Neue Fenster im aktuellen Verzeichnis öffnen

Im Terminal Multiplexer tmux fehlt seit Version 1.9a vom 20. Februar 2014 neue Fenster (Panes) mit dem Arbeitsverzeichnis $HOME. Befindet man sich also im Verzeichnis /tmp/foo und erstellt ein neues Fenster, befindet man sich sofort wieder im Verzeichnis /home/username. Diese Einstellung kann man aber überschreiben.

Aus dem Changelog

Im Changelog sieht man, dass die Option default-path nicht mehr existiert. Mit dieser Option konnte man den Pfad für neue Fenster einstellen.

Incompatible Changes
====================
[...]
* 'default-path' has been removed.  The new-window command accepts '-c' to
  cater for this.  The previous value of "." can be replaced with: 'neww -c
  $PWD', the previous value of '' which meant current path of the pane can
  be specified as:  'neww -c "#{pane_current_path}"'

Folgendes geht also nicht mehr:

# Default Path for new Panes
set-option default-path "/my/favourite/directory"

Nötige Änderungen in der Konfigurationsdatei .tmux.conf

Folgende Konfiguration kommt in die Datei ~/.tmux.conf, welche die Tastenkombination für neue Fenster überschreibt (Bind-Key c):

# Open new pane at current location
bind-key c new-window -c "#{pane_current_path}"
bind-key '"' split-window -h -c "#{pane_current_path}"
bind-key % split-window -v -c "#{pane_current_path}"

Falls man weitere Befehle in der Konfiguration hat, welche neue Fenster erzeugen, muss man diese ebenfalls anpassen:

# Panel splitter
bind-key | split-window -h -c "#{pane_current_path}"
bind-key - split-window -v -c "#{pane_current_path}"

Somit öffnen neue Fenster sofort im aktuellen Pfad.

Links und weitere Informationen

Leave a Comment