Display IP addresses in tmux
I always forget my IP addresses and get tired of constantly running ifconfig
or ip addr
. Now I
have tmux display them for me!
Here’s how I did it!
editing tmux.conf
Add the following lines to your tmux.conf file in order to display the IP addresses in the bottom right window.
set -g status-right "enp0s3: [#(get-ip.sh enp0s3)] enp0s8:[#(get-ip.sh enp0s8)] "
set -g status-right-length 50
The first line tells tmux to run my get-ip.sh script to print the IP addresses for interfaces enp0s3 and enp0s8. I’ve written about this script before but it is essentially just a wrapper for the command:
ip addr show <INTERFACE_NAME> | grep -m 1 inet | awk '{print $2}' | cut -d / -f 1
You can use either the builtin shell commands or download my get-ip script. Either will work fine.
The second line adjusts the padding so it looks nice in the tmux window.
hungry for more?
Want to make other cool edits to tmux? View my entire tmux.conf script, and more, here on GitHub.