a56eac7a71a774a4d97bb9456f36b8eb495329d5

Author
Hong <hong@topbug.net>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Use OSTYPE instead of uname whenever possible for better speed. (#5496)

Diff

 1diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh
 2index 12bcd284980f68a57b5c789b5bfc7c39b15ac9fd..039a59d2a33614de57053c85864f7f071c24a890 100644
 3--- a/lib/theme-and-appearance.zsh
 4+++ b/lib/theme-and-appearance.zsh
 5@@ -6,11 +6,11 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad"
 6 
 7 if [[ "$DISABLE_LS_COLORS" != "true" ]]; then
 8   # Find the option for using colors in ls, depending on the version
 9-  if [[ "$(uname -s)" == "NetBSD" ]]; then
10+  if [[ "$OSTYPE" == netbsd* ]]; then
11     # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
12     # otherwise, leave ls as is, because NetBSD's ls doesn't support -G
13     gls --color -d . &>/dev/null && alias ls='gls --color=tty'
14-  elif [[ "$(uname -s)" == "OpenBSD" ]]; then
15+  elif [[ "$OSTYPE" == openbsd* ]]; then
16     # On OpenBSD, "gls" (ls from GNU coreutils) and "colorls" (ls from base,
17     # with color and multibyte support) are available from ports.  "colorls"
18     # will be installed on purpose and can't be pulled in by installing
19diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
20index 0bb9e77f09174d8b08da465229157089dc00962b..da229cf3547888aaf5993f755dcd0dda5ec4af64 100644
21--- a/plugins/battery/battery.plugin.zsh
22+++ b/plugins/battery/battery.plugin.zsh
23@@ -64,7 +64,7 @@ if [[ "$OSTYPE" = darwin* ]] ; then
24     [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]]
25   }
26 
27-elif [[ $(uname) == "Linux"  ]] ; then
28+elif [[ "$OSTYPE" = linux*  ]] ; then
29 
30   function battery_is_charging() {
31     ! [[ $(acpi 2>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]]
32diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash
33index e3918c87e3adf32a9d7a4f0320c92c497376b9b5..8ce6b5c5f70d7bd72bcc354305b4dc6bfe39ca27 100644
34--- a/plugins/gitfast/git-completion.bash
35+++ b/plugins/gitfast/git-completion.bash
36@@ -2771,6 +2771,6 @@ __git_complete gitk __gitk_main
37 # when the user has tab-completed the executable name and consequently
38 # included the '.exe' suffix.
39 #
40-if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
41+if [[ "$OSTYPE" = cygwin* ]]; then
42 __git_complete git.exe __git_main
43 fi
44diff --git a/plugins/sublime/sublime.plugin.zsh b/plugins/sublime/sublime.plugin.zsh
45index 75a39eab137cd7154df92979611bb05e5c6dcef1..f84b7032af775d08437f45f994cde5c7f169d441 100644
46--- a/plugins/sublime/sublime.plugin.zsh
47+++ b/plugins/sublime/sublime.plugin.zsh
48@@ -1,4 +1,4 @@
49-if [[ $('uname') == 'Linux' ]]; then
50+if [[ "$OSTYPE" == linux* ]]; then
51     local _sublime_linux_paths > /dev/null 2>&1
52     _sublime_linux_paths=(
53         "$HOME/bin/sublime_text"
54diff --git a/plugins/zsh-navigation-tools/_n-kill b/plugins/zsh-navigation-tools/_n-kill
55index 8a4ec9da711cfda4610a40d6466af012cef05c9c..6f5d47971954345c42a9f6a267da02b7f3e42d27 100644
56--- a/plugins/zsh-navigation-tools/_n-kill
57+++ b/plugins/zsh-navigation-tools/_n-kill
58@@ -10,8 +10,8 @@ integer cygwin=0
59 local IFS="
60 "
61 
62-case "$(uname)" in
63-    CYGWIN*) list=( `command ps -Wa` ); cygwin=1 ;;
64+case "$OSTYPE" in
65+    cygwin*) list=( `command ps -Wa` ); cygwin=1 ;;
66     *) list=( `command ps -o pid,uid,command -A` ) ;;
67 esac
68 
69diff --git a/plugins/zsh-navigation-tools/n-kill b/plugins/zsh-navigation-tools/n-kill
70index 0d10565e4f9b1ce45d7474a845842c0e04dbc51c..76050f9694726852e9bd5e70c2181c12500987b2 100644
71--- a/plugins/zsh-navigation-tools/n-kill
72+++ b/plugins/zsh-navigation-tools/n-kill
73@@ -42,8 +42,8 @@ NLIST_NONSELECTABLE_ELEMENTS=( 1 )
74 
75 type ps 2>/dev/null 1>&2 || { echo >&2 "Error: \`ps' not found"; return 1 }
76 
77-case "$(uname)" in
78-    CYGWIN*) list=( `command ps -Wa` )  ;;
79+case "$OSTYPE" in
80+    cygwin*) list=( `command ps -Wa` )  ;;
81     *) list=( `command ps -o pid,uid,command -A` ) ;;
82 esac
83