Skip to content

Commit

Permalink
[tmux] Add ip address to status bar
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelRobitaille committed Oct 28, 2021
1 parent b1f0a19 commit 282adc1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tmux/.tmux.conf
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ bind -n C-S-Right resize-pane -R 1
#
set -g status-left ''
set -g status-right ''
set -g status-right-length 140
set -g status-right '#(~/.dotfiles/tmux/ip_addresses.sh)'
set -g status-bg terminal
set -g status-fg white
Expand Down
8 changes: 8 additions & 0 deletions tmux/ip_addresses.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
for iface in $(ip addr list | awk -F': ' '/^[0-9]/ {print $2}'); do
short=${iface:0:3}
if [ $short = eth ] || [ $short = enp ] || [ $short = eno ] || [ $short = wlp ]; then
ip=$(ip addr show dev $iface 2>/dev/null | awk '$1 == "inet" {split($2, a, "/"); print a[1]}' | xargs | tr ' ' '/')
echo -n "#[bg=blue, fg=colour232, bold] $iface #[bg=default, fg=default, none]"
[ "$ip" = "" ] && echo -n " down " || echo -n " $ip "
fi
done

0 comments on commit 282adc1

Please sign in to comment.