mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-29 14:36:04 +02:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b37d4878ed |
@@ -100,7 +100,13 @@ done
|
|||||||
# Figure out the SHORT hostname
|
# Figure out the SHORT hostname
|
||||||
if [[ "$OSTYPE" = darwin* ]]; then
|
if [[ "$OSTYPE" = darwin* ]]; then
|
||||||
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
# macOS's $HOST changes with dhcp, etc. Use LocalHostName if possible.
|
||||||
|
# When $HOST is the Bonjour name (<LocalHostName>.local) it already is the
|
||||||
|
# LocalHostName, so don't fork scutil to look it up.
|
||||||
|
if [[ "$HOST" = *.local ]]; then
|
||||||
|
SHORT_HOST="${HOST%.local}"
|
||||||
|
else
|
||||||
SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
|
SHORT_HOST=$(scutil --get LocalHostName 2>/dev/null) || SHORT_HOST="${HOST/.*/}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
SHORT_HOST="${HOST/.*/}"
|
SHORT_HOST="${HOST/.*/}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,25 +1,6 @@
|
|||||||
# Git version checking
|
# Git version checking
|
||||||
autoload -Uz is-at-least
|
autoload -Uz is-at-least
|
||||||
# Running `git version` forks on every startup, so cache the result for a day
|
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
||||||
# in $ZSH_CACHE_DIR, keyed on the git command path, mtime, and exec path.
|
|
||||||
() {
|
|
||||||
local cache="$ZSH_CACHE_DIR/git-version" key exec_path
|
|
||||||
local -a stat lines
|
|
||||||
zmodload -F zsh/stat b:zstat
|
|
||||||
zstat -A stat +mtime -- "$commands[git]" 2>/dev/null
|
|
||||||
exec_path="$(git --exec-path 2>/dev/null)"
|
|
||||||
key="$commands[git] $stat[1] $exec_path"
|
|
||||||
|
|
||||||
lines=("$cache"(Nm-1))
|
|
||||||
(( $#lines )) && lines=("${(@f)$(<"$cache")}")
|
|
||||||
if [[ "$lines[1]" = "$key" ]]; then
|
|
||||||
git_version="$lines[2]"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
git_version="${${(As: :)$(git version 2>/dev/null)}[3]}"
|
|
||||||
[[ ! -w "$ZSH_CACHE_DIR" ]] || print -rl -- "$key" "$git_version" >| "$cache"
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Functions Current
|
# Functions Current
|
||||||
|
|||||||
Reference in New Issue
Block a user