From 5e328e3a9c0784521ae4170f7958183c352bae83 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Fri, 11 Jul 2014 18:41:49 +0530 Subject: [PATCH 1/4] Solaris portability tweaks. --- lib/completion.zsh | 7 ++++++- oh-my-zsh.sh | 1 + plugins/colored-man/colored-man.plugin.zsh | 21 +++++++++++++++++++++ tools/check_for_upgrade.sh | 8 +++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index fa1d97f4..faea3611 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -25,7 +25,12 @@ bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" +if [ "$PLAT" = "SunOS" ] +then + zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm" +else + zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm -w -w" +fi # disable named-directories autocompletion zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index c217b91b..4683c2bc 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,3 +1,4 @@ +PLAT=`uname -s` # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh diff --git a/plugins/colored-man/colored-man.plugin.zsh b/plugins/colored-man/colored-man.plugin.zsh index 56056284..4956f434 100644 --- a/plugins/colored-man/colored-man.plugin.zsh +++ b/plugins/colored-man/colored-man.plugin.zsh @@ -1,3 +1,21 @@ +if [ "${PLAT}" = "SunOS" ] +then + if [ ! -x ${HOME}/bin/nroff ] + then + mkdir -p ${HOME}/bin + cat > ${HOME}/bin/nroff < Date: Tue, 16 Sep 2014 22:29:52 +0530 Subject: [PATCH 2/4] Update Solaris changes to use OSTYPE and zsh datetime module. --- lib/completion.zsh | 2 +- oh-my-zsh.sh | 1 - plugins/colored-man/colored-man.plugin.zsh | 2 +- tools/check_for_upgrade.sh | 12 ++++-------- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/completion.zsh b/lib/completion.zsh index faea3611..83b6efb6 100644 --- a/lib/completion.zsh +++ b/lib/completion.zsh @@ -25,7 +25,7 @@ bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu select zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01' -if [ "$PLAT" = "SunOS" ] +if [ "$OSTYPE[0,7]" = "solaris" ] then zstyle ':completion:*:*:*:*:processes' command "ps -u `whoami` -o pid,user,comm" else diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 4683c2bc..c217b91b 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,4 +1,3 @@ -PLAT=`uname -s` # Check for updates on initial load... if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh diff --git a/plugins/colored-man/colored-man.plugin.zsh b/plugins/colored-man/colored-man.plugin.zsh index 4956f434..5c613f49 100644 --- a/plugins/colored-man/colored-man.plugin.zsh +++ b/plugins/colored-man/colored-man.plugin.zsh @@ -1,4 +1,4 @@ -if [ "${PLAT}" = "SunOS" ] +if [ "$OSTYPE[0,7]" = "solaris" ] then if [ ! -x ${HOME}/bin/nroff ] then diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 1aba9a27..0e8845ab 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -1,13 +1,9 @@ -#!/bin/sh +#!/usr/bin/env zsh + +zmodload zsh/datetime -PLAT=`uname -s` function _current_epoch() { - if [ "$PLAT" = "SunOS" ] - then - echo $(($(perl -e 'print time') / 60 / 60 / 24)) - else - echo $(($(date +%s) / 60 / 60 / 24)) - fi + echo $EPOCHSECONDS } function _update_zsh_update() { From 90762eee49efcdfd6b92ad5d5d9e5f43d113ae0b Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Wed, 17 Sep 2014 11:11:48 +0530 Subject: [PATCH 3/4] Convert epoch_target from days to seconds. --- tools/check_for_upgrade.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 0e8845ab..f49bb151 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -22,6 +22,8 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi +epoch_target_seconds=$((epoch_target * 86400)) + [ -f ~/.profile ] && source ~/.profile # Cancel upgrade if the current user doesn't have write permissions for the @@ -37,7 +39,7 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target ] + if [ $epoch_diff -gt $epoch_target_seconds ] then if [ "$DISABLE_UPDATE_PROMPT" = "true" ] then From 3a3973284534c318e2cb987a0db1121302d04e10 Mon Sep 17 00:00:00 2001 From: Moinak Ghosh Date: Tue, 14 Oct 2014 12:05:01 +0530 Subject: [PATCH 4/4] Change to epoch target in days instead of seconds. --- tools/check_for_upgrade.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index f49bb151..a8ba4820 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -3,7 +3,7 @@ zmodload zsh/datetime function _current_epoch() { - echo $EPOCHSECONDS + echo $(( $EPOCHSECONDS / 60 / 60 / 24 )) } function _update_zsh_update() { @@ -22,8 +22,6 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi -epoch_target_seconds=$((epoch_target * 86400)) - [ -f ~/.profile ] && source ~/.profile # Cancel upgrade if the current user doesn't have write permissions for the @@ -39,7 +37,7 @@ then fi epoch_diff=$(($(_current_epoch) - $LAST_EPOCH)) - if [ $epoch_diff -gt $epoch_target_seconds ] + if [ $epoch_diff -gt $epoch_target ] then if [ "$DISABLE_UPDATE_PROMPT" = "true" ] then