From a56eac7a71a774a4d97bb9456f36b8eb495329d5 Mon Sep 17 00:00:00 2001 From: Hong Date: Mon, 10 Oct 2016 13:24:30 -0700 Subject: [PATCH] Use OSTYPE instead of uname whenever possible for better speed. (#5496) --- lib/theme-and-appearance.zsh | 4 ++-- plugins/battery/battery.plugin.zsh | 2 +- plugins/gitfast/git-completion.bash | 2 +- plugins/sublime/sublime.plugin.zsh | 2 +- plugins/zsh-navigation-tools/_n-kill | 4 ++-- plugins/zsh-navigation-tools/n-kill | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 12bcd284..039a59d2 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -6,11 +6,11 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad" if [[ "$DISABLE_LS_COLORS" != "true" ]]; then # Find the option for using colors in ls, depending on the version - if [[ "$(uname -s)" == "NetBSD" ]]; then + if [[ "$OSTYPE" == netbsd* ]]; then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G gls --color -d . &>/dev/null && alias ls='gls --color=tty' - elif [[ "$(uname -s)" == "OpenBSD" ]]; then + elif [[ "$OSTYPE" == openbsd* ]]; then # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base, # with color and multibyte support) are available from ports. "colorls" # will be installed on purpose and can't be pulled in by installing diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 0bb9e77f..da229cf3 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -64,7 +64,7 @@ if [[ "$OSTYPE" = darwin* ]] ; then [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]] } -elif [[ $(uname) == "Linux" ]] ; then +elif [[ "$OSTYPE" = linux* ]] ; then function battery_is_charging() { ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash index e3918c87..8ce6b5c5 100644 --- a/plugins/gitfast/git-completion.bash +++ b/plugins/gitfast/git-completion.bash @@ -2771,6 +2771,6 @@ __git_complete gitk __gitk_main # when the user has tab-completed the executable name and consequently # included the '.exe' suffix. # -if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then +if [[ "$OSTYPE" = cygwin* ]]; then __git_complete git.exe __git_main fi diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh index 75a39eab..f84b7032 100644 --- a/plugins/sublime/sublime.plugin.zsh +++ b/plugins/sublime/sublime.plugin.zsh @@ -1,4 +1,4 @@ -if [[ $('uname') == 'Linux' ]]; then +if [[ "$OSTYPE" == linux* ]]; then local _sublime_linux_paths > /dev/null 2>&1 _sublime_linux_paths=( "$HOME/bin/sublime_text" diff --git a/plugins/zsh-navigation-tools/_n-kill b/plugins/zsh-navigation-tools/_n-kill index 8a4ec9da..6f5d4797 100644 --- a/plugins/zsh-navigation-tools/_n-kill +++ b/plugins/zsh-navigation-tools/_n-kill @@ -10,8 +10,8 @@ integer cygwin=0 local IFS=" " -case "$(uname)" in - CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;; +case "$OSTYPE" in + cygwin*) list=( `command ps -Wa` ); cygwin=1 ;; *) list=( `command ps -o pid,uid,command -A` ) ;; esac diff --git a/plugins/zsh-navigation-tools/n-kill b/plugins/zsh-navigation-tools/n-kill index 0d10565e..76050f96 100644 --- a/plugins/zsh-navigation-tools/n-kill +++ b/plugins/zsh-navigation-tools/n-kill @@ -42,8 +42,8 @@ NLIST_NONSELECTABLE_ELEMENTS=( 1 ) type ps 2>/dev/null 1>&2 || { echo >&2 "Error: \`ps' not found"; return 1 } -case "$(uname)" in - CYGWIN*) list=( `command ps -Wa` ) ;; +case "$OSTYPE" in + cygwin*) list=( `command ps -Wa` ) ;; *) list=( `command ps -o pid,uid,command -A` ) ;; esac -- GitLab