Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
napalm255 committed Dec 13, 2014
2 parents 13ab72f + 4656d42 commit 68d8e36
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 46 deletions.
11 changes: 1 addition & 10 deletions plugins/wan_ip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@ run_plugin() {
local wan_ip

if [ -f "$tmp_file" ]; then
if shell_is_osx || shell_is_bsd; then
stat >/dev/null 2>&1 && is_gnu_stat=false || is_gnu_stat=true
if [ "$is_gnu_stat" == "true" ];then
last_update=$(stat -c "%Y" ${tmp_file})
else
last_update=$(stat -f "%m" ${tmp_file})
fi
elif shell_is_linux || [ -z $is_gnu_stat]; then
last_update=$(stat -c "%Y" ${tmp_file})
fi
last_update=$(stat -c "%Y" ${tmp_file})

time_now=$(date +%s)
update_period=900
Expand Down
69 changes: 33 additions & 36 deletions powertmux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ __powertmux_colors() {
powertmux_plugin[4]=${previous_background_color:-$POWERTMUX_DEFAULT_BACKGROUND_COLOR}
fi

if __plugin_separator_is_thin; then
if __powertmux_plugin_separator_is_thin; then
powertmux_plugin[5]=${powertmux_plugin[2]}
else
powertmux_plugin[5]=${powertmux_plugin[1]}
Expand All @@ -142,41 +142,38 @@ __powertmux_process() {
local separator_background_color=${powertmux_plugin[4]}
local separator_foreground_color=${powertmux_plugin[5]}

eval "__print_${side}_plugin ${plugin_index} ${background_color} ${foreground_color} ${separator} ${separator_background_color} ${separator_foreground_color}"
eval "__powertmux_print_plugin ${side} ${plugin_index} ${background_color} ${foreground_color} ${separator} ${separator_background_color} ${separator_foreground_color}"
done
}

__print_colored_content() {
__powertmux_print_colored_content() {
echo -n "#[fg=colour$3, bg=colour$2]"
echo -n "$1"
echo -n "#[default]"
}

__print_left_plugin() {
local content=${powertmux_plugin_contents[$1]}
local content_background_color=$2
local content_foreground_color=$3
local separator=$4
local separator_background_color=$5
local separator_foreground_color=$6
__powertmux_print_plugin() {
local side=$1
local content=${powertmux_plugin_contents[$2]}
local content_background_color=$3
local content_foreground_color=$4
local separator=$5
local separator_background_color=$6
local separator_foreground_color=$7

__print_colored_content "$content" $content_background_color $content_foreground_color
__print_colored_content $separator $separator_background_color $separator_foreground_color
}

__print_right_plugin() {
local content=${powertmux_plugin_contents[$1]}
local content_background_color=$2
local content_foreground_color=$3
local separator=$4
local separator_background_color=$5
local separator_foreground_color=$6

__print_colored_content $separator $separator_background_color $separator_foreground_color
__print_colored_content "$content" $content_background_color $content_foreground_color
case "${side}" in
left)
__powertmux_print_colored_content "$content" $content_background_color $content_foreground_color
__powertmux_print_colored_content $separator $separator_background_color $separator_foreground_color
;;
right)
__powertmux_print_colored_content $separator $separator_background_color $separator_foreground_color
__powertmux_print_colored_content "$content" $content_background_color $content_foreground_color
;;
esac
}

__plugin_separator_is_thin() {
__powertmux_plugin_separator_is_thin() {
[[ ${powertmux_plugin[3]} == $POWERTMUX_SEPARATOR_LEFT_THIN || \
${powertmux_plugin[3]} == $POWERTMUX_SEPARATOR_RIGHT_THIN ]];
}
Expand Down Expand Up @@ -246,14 +243,14 @@ roll_text() {
}

# Get the current path in the plugin.
get_tmux_cwd() {
local env_name=$(tmux display -p "TMUXPWD_#D" | tr -d %)
local env_val=$(tmux show-environment | grep --color=never "$env_name")
# The version below is still quite new for tmux. Uncomment this in the future :-)
#local env_val=$(tmux show-environment "$env_name" 2>&1)

if [[ ! $env_val =~ "unknown variable" ]]; then
local tmux_pwd=$(echo "$env_val" | sed 's/^.*=//')
echo "$tmux_pwd"
fi
}
#get_tmux_cwd() {
# local env_name=$(tmux display -p "TMUXPWD_#D" | tr -d %)
# local env_val=$(tmux show-environment | grep --color=never "$env_name")
# # The version below is still quite new for tmux. Uncomment this in the future :-)
# #local env_val=$(tmux show-environment "$env_name" 2>&1)
#
# if [[ ! $env_val =~ "unknown variable" ]]; then
# local tmux_pwd=$(echo "$env_val" | sed 's/^.*=//')
# echo "$tmux_pwd"
# fi
#}

0 comments on commit 68d8e36

Please sign in to comment.