#!/bin/sh
#
# for use in tmux.conf
# set -g status-right "#{prefix_highlight} #[fg=yellow]#(~/.scripts/tmux-runtime) #[fg=green]#(tmux-mem-cpu-load --colors -a 0 --powerline-right --interval 1) #[fg=green]#[fg=black,bg=green] #{network_bandwidth} #[default]"

# check if env TMUX exists
if [ -z "${TMUX-}" ]; then
  exit 1
fi

sh_pid=$(tmux display-message -p "#{pane_pid}")
pid=$(pgrep -P "${sh_pid}")
if [ -z "${pid}" ]; then
  exit 0
fi
etime=$(ps -o etime= -p "${pid}")
echo "${etime}"
