To automatically run tmux when opening a Kitty terminal window in i3 on Fedora 39, you can configure this in a couple of ways:
- Using i3 config:
Edit your i3 configuration file (usually located at ~/.config/i3/config) and modify the keybinding for launching Kitty to include the tmux command. Add or modify this line:
bindsym $mod+Return exec kitty -e tmux
This will launch Kitty with tmux every time you use the keybinding to open a new terminal window[4].
- Using Kitty’s configuration:
You can configure Kitty to automatically launch tmux on startup:
a. Create a launch.conf file in your Kitty config directory:
mkdir -p ~/.config/kitty
touch ~/.config/kitty/launch.conf
b. Add the following line to launch.conf:
launch sh -c "tmux"
c. Edit your kitty.conf file (usually at ~/.config/kitty/kitty.conf) and add this line:
startup_session launch.conf
This method will make Kitty launch tmux automatically regardless of how you open it[4].
- Using your shell’s configuration:
If you’re using bash or zsh, you can add a condition to your shell’s configuration file (~/.bashrc or ~/.zshrc) to start tmux automatically when Kitty is launched:
if [ -z "$TMUX" ] && [ "$TERM" = "xterm-kitty" ]; then
tmux attach || exec tmux new-session && exit
fi
This script checks if you’re not already in a tmux session and if the terminal is Kitty, then it either attaches to an existing session or creates a new one[4].
The first method using i3 config is probably the simplest and most straightforward for your use case with i3 window manager. It ensures that tmux is launched every time you open Kitty using i3’s keybinding.
Remember to restart i3 (usually with $mod+Shift+r) or re-login after making these changes for them to take effect.
Citations: [1] https://dev.to/wesen/comment/1np4j [2] https://unix.stackexchange.com/questions/470676/tmux-under-kitty-terminal [3] https://sw.kovidgoyal.net/kitty/conf/ [4] https://github.com/kovidgoyal/kitty/issues/2246 [5] https://news.ycombinator.com/item?id=33943537