mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 03:26:42 +00:00
chore(zsh): various tweaks to zsh env setup and helpers
This commit is contained in:
@@ -17,7 +17,7 @@
|
|||||||
<key>EnvironmentVariables</key>
|
<key>EnvironmentVariables</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>PATH</key>
|
<key>PATH</key>
|
||||||
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin</string>
|
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>StartCalendarInterval</key>
|
<key>StartCalendarInterval</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
export POW_DST_PORT=88
|
export POW_DST_PORT=88
|
||||||
export HOME=~
|
export HOME=~
|
||||||
export PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:/usr/local/bin:$PATH"
|
export PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:/usr/local/bin:/opt/homebrew/bin:$PATH"
|
||||||
|
|||||||
@@ -2,10 +2,6 @@
|
|||||||
# Google Cloud SDK setup.
|
# Google Cloud SDK setup.
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -f '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc' ]; then
|
|
||||||
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Lazy load gcloud shell completion on first use.
|
# Lazy load gcloud shell completion on first use.
|
||||||
if command-exists gcloud; then
|
if command-exists gcloud; then
|
||||||
_python_argcomplete() {
|
_python_argcomplete() {
|
||||||
@@ -17,8 +13,8 @@ if command-exists gcloud; then
|
|||||||
|
|
||||||
load-gcloud-completion() {
|
load-gcloud-completion() {
|
||||||
unset -f load-gcloud-completion _python_argcomplete
|
unset -f load-gcloud-completion _python_argcomplete
|
||||||
if [ -f '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc' ]; then
|
if [ -n "$HOMEBREW_PREFIX" ]; then
|
||||||
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc'
|
source-if-exists "${HOMEBREW_PREFIX}/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -23,11 +23,13 @@ if command-exists kubectl; then
|
|||||||
}
|
}
|
||||||
_setup-kubectl-completion
|
_setup-kubectl-completion
|
||||||
|
|
||||||
|
if command-exists brew-prefix; then
|
||||||
switch() {
|
switch() {
|
||||||
unset -f switch
|
unset -f switch
|
||||||
source "$(brew --prefix switch)/switch.sh"
|
source "$(brew-prefix switch)/switch.sh"
|
||||||
switch "$@"
|
switch "$@"
|
||||||
}
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
export KREW_ROOT="$HOME/.krew"
|
export KREW_ROOT="$HOME/.krew"
|
||||||
path_append "${KREW_ROOT}/bin"
|
path_append "${KREW_ROOT}/bin"
|
||||||
|
|||||||
33
zshenv
33
zshenv
@@ -68,6 +68,12 @@ command-exists() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
source-if-exists() {
|
||||||
|
if [ -f "$1" ]; then
|
||||||
|
source "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# System Environment Setup
|
# System Environment Setup
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@@ -126,6 +132,26 @@ if [ -f "/opt/homebrew/bin/brew" ]; then
|
|||||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if command-exists brew; then
|
||||||
|
typeset -A _brew_prefix_cache
|
||||||
|
|
||||||
|
brew-prefix() {
|
||||||
|
local package="$1"
|
||||||
|
|
||||||
|
if [[ -z "$package" ]]; then
|
||||||
|
package="__none__"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${_brew_prefix_cache[$package]}" ]]; then
|
||||||
|
echo "${_brew_prefix_cache[$package]}"
|
||||||
|
else
|
||||||
|
local result=$(brew --prefix "$package")
|
||||||
|
_brew_prefix_cache[$package]=$result
|
||||||
|
echo $result
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# Linuxbrew
|
# Linuxbrew
|
||||||
if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
|
if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
|
||||||
# Inline linux-brew setup to improve shell startup speed by around 200ms.
|
# Inline linux-brew setup to improve shell startup speed by around 200ms.
|
||||||
@@ -209,11 +235,12 @@ path_prepend "$HOME/.local/share/rtx/bin"
|
|||||||
path_prepend "$HOME/.local/share/rtx/shims"
|
path_prepend "$HOME/.local/share/rtx/shims"
|
||||||
|
|
||||||
# orbstack setup
|
# orbstack setup
|
||||||
if [ -f "$HOME/.orbstack/shell/init.zsh" ]; then
|
source-if-exists "$HOME/.orbstack/shell/init.zsh"
|
||||||
source "$HOME/.orbstack/shell/init.zsh"
|
|
||||||
fi
|
|
||||||
path_prepend "$HOME/.orbstack/bin"
|
path_prepend "$HOME/.orbstack/bin"
|
||||||
|
|
||||||
|
# Google Cloud SDK setup
|
||||||
|
source-if-exists "${HOMEBREW_PREFIX}/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# Path setup for select binaries installed with zinit
|
# Path setup for select binaries installed with zinit
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|||||||
5
zshrc
5
zshrc
@@ -116,6 +116,11 @@ fi
|
|||||||
# Prompt
|
# Prompt
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
|
if ! command-exists starship; then
|
||||||
|
read -q 'REPLY?starship is not installed, install with `rtx install starship`? [y/N]:' &&
|
||||||
|
echo && rtx install starship
|
||||||
|
fi
|
||||||
|
|
||||||
if command-exists starship; then
|
if command-exists starship; then
|
||||||
eval "$(starship init zsh --print-full-init)"
|
eval "$(starship init zsh --print-full-init)"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user