Refactor shell setup into ~/.zshenv and ~/.zshrc files

It was time to split the environment related stuff out to ~/.zshenv,
leaving my ~/.zshrc file specifically for setup of interactive shells.
This commit is contained in:
2020-02-22 14:27:19 +00:00
parent d283fc9474
commit 80c77c8c2b
20 changed files with 230 additions and 203 deletions

View File

@@ -27,6 +27,20 @@ alias di="colordiff"
alias devnullsmtp="java -jar $DOTBIN/DevNullSmtp.jar"
alias open_ports="sudo lsof -i -P | grep --color=never -i \"listen\""
# Homebrew
if (( $+commands[brew] )); then
alias br="brew"
alias ca="brew cask"
alias cask="brew cask"
alias bb="brew bundle"
alias bbg="brew bundle --global"
fi
# Flutter
if (( $+commands[flutter] )); then
alias fl="flutter"
fi
# Flush DNS cache
alias flush_dns="dscacheutil -flushcache"

View File

@@ -1,11 +0,0 @@
#
# Android SDK environment setup.
#
if [ -d "$HOME/Library/Android/sdk" ]; then
export ANDROID_HOME="$HOME/Library/Android/sdk"
path_append "$ANDROID_HOME/emulator"
path_append "$ANDROID_HOME/tools"
path_append "$ANDROID_HOME/tools/bin"
path_append "$ANDROID_HOME/platform-tools"
fi

View File

@@ -7,5 +7,5 @@ alias dc="docker-compose"
alias co="docker-compose"
docker_remove_exited () {
docker rm $(docker ps -f="status=exited" -q)
docker rm "$(docker ps -f='status=exited' -q)"
}

View File

@@ -2,7 +2,7 @@
# Emacs
#
# OS X systems.
# macOS systems
if [ -f "/Applications/Emacs.app/Contents/MacOS/Emacs" ]; then
alias emacs="env TERM=screen-24bit /Applications/Emacs.app/Contents/MacOS/Emacs -nw"
fi
@@ -10,8 +10,3 @@ fi
if [ -f "/Applications/Emacs.app/Contents/MacOS/bin/emacsclient" ]; then
alias emacsclient="env TERM=screen-24bit /Applications/Emacs.app/Contents/MacOS/bin/emacsclient"
fi
# *nix systems.
if [ -d "/opt/emacs/bin" ]; then
path_append "/opt/emacs/bin"
fi

View File

@@ -1,12 +0,0 @@
#
# Flutter environment setup
#
if [ -d "/opt/flutter/bin" ]; then
path_append "/opt/flutter/bin"
alias fl="flutter"
if [ -d "/opt/flutter/bin/cache/dart-sdk/bin" ]; then
path_append "/opt/flutter/bin/cache/dart-sdk/bin"
fi
fi

View File

@@ -1,7 +0,0 @@
#
# Use gnu-getopt if it's available
#
if [ -f "/usr/local/opt/gnu-getopt/bin/getopt" ]; then
path_prepend "/usr/local/opt/gnu-getopt/bin"
fi

View File

@@ -1,10 +1,7 @@
#
# Go (golang) environment setup.
# Go (golang) setup.
#
export GOPATH="$HOME/.go"
path_prepend "$GOPATH/bin"
install_go_global_packages () {
local packages=(
github.com/akavel/up

View File

@@ -1,12 +0,0 @@
#
# Homebrew setup.
#
export HOMEBREW_NO_ANALYTICS=1
# Aliases
alias br="brew"
alias ca="brew cask"
alias cask="brew cask"
alias bb="brew bundle"
alias bbg="brew bundle --global"

View File

@@ -6,8 +6,6 @@ alias kc="kubectl"
alias hl="helm"
alias mk="minikube"
export KUBECONFIG="$HOME/.kube/config:.kube/config"
if [ $commands[kubectl] ]; then
if (( $+commands[kubectl] )); then
eval "$(kubectl completion zsh)"
fi

View File

@@ -5,7 +5,7 @@
alias le="less"
# Enable syntax highlighting via source-highlight
if [ $commands[src-hilite-lesspipe.sh] ]; then
if (( $+commands[src-hilite-lesspipe.sh] )); then
export LESSOPEN="| src-hilite-lesspipe.sh %s"
export LESS=" -R "
fi

55
zsh/macos.zsh Normal file
View File

@@ -0,0 +1,55 @@
#
# macOS Specific
#
# Fix wifi issues on OS X 10.10.x Yosemite.
# - from: https://medium.com/@mariociabarra/wifried-ios-8-wifi-performance-issues-3029a164ce94
alias fix_wifi="sudo ifconfig awdl0 down"
alias unfix_wifi="sudo ifconfig awdl0 up"
# Disable the system built-in cmd+ctrl+d global hotkey to lookup word in
# dictionary on OS X. Must reboot after running.
# - from: ://apple.stackexchange.com/a/114269
osx-disable-lookup-word-hotkey () {
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 \
'<dict><key>enabled</key><false/></dict>'
echo "Command-Control-D hotkey disabled. Please reboot to take effect."
}
#
# Power management
#
# Set all relevant power management settings to force the machine to save a
# sleep image and immediately enter "standby" along with FileVault destroying
# disk decryption keys.
pm-hibernate () {
sudo pmset -a hibernatemode 25
sudo pmset -a standby 1
sudo pmset -a standbydelayhigh 0
sudo pmset -a standbydelaylow 0
sudo pmset -a autopoweroffdelay 0
sudo pmset -a destroyfvkeyonstandby 1
}
# Restore all settings modified by pm-hibernate to their defaults, effectively
# restoring default sleep behavior for macOS laptops.
pm-safesleep () {
sudo pmset -a hibernatemode 3
sudo pmset -a standbydelayhigh 86400
sudo pmset -a standbydelaylow 0
sudo pmset -a autopoweroffdelay 28800
sudo pmset -a destroyfvkeyonstandby 0
}
# Trigger hibernation now.
hibernate () {
pm-hibernate
sudo pmset sleepnow
}
# Trigger a safe-sleep now.
safesleep () {
pm-safesleep
sudo pmset sleepnow
}

View File

@@ -40,8 +40,3 @@ install_node_global_packages () {
npm install -g "${packages[@]}"
}
# Load nvm if it's available
if [ -f "$HOME/.nvm/nvm.sh" ]; then
source "$HOME/.nvm/nvm.sh"
fi

View File

@@ -1,69 +0,0 @@
#
# OSX Related
#
if [[ "$(uname)" == "Darwin" ]]; then
# Fix wifi issues on OS X 10.10.x Yosemite.
# - from: https://medium.com/@mariociabarra/wifried-ios-8-wifi-performance-issues-3029a164ce94
alias fix_wifi="sudo ifconfig awdl0 down"
alias unfix_wifi="sudo ifconfig awdl0 up"
# Disable the system built-in cmd+ctrl+d global hotkey to lookup word in
# dictionary on OS X. Must reboot after running.
# - from: ://apple.stackexchange.com/a/114269
osx-disable-lookup-word-hotkey() {
defaults write com.apple.symbolichotkeys AppleSymbolicHotKeys -dict-add 70 \
'<dict><key>enabled</key><false/></dict>'
echo "Command-Control-D hotkey disabled. Please reboot to take effect."
}
# Show hidden files in Finder.
show_files() {
defaults write com.apple.finder AppleShowAllFiles YES
killall Finder "/System/Library/CoreServices/Finder.app"
}
# Don't show hidden files in Finder.
hide_files() {
defaults write com.apple.finder AppleShowAllFiles NO
killall Finder "/System/Library/CoreServices/Finder.app"
}
#
# Power management
#
# Set all relevant power management settings to force the machine to save a
# sleep image and immediately enter "standby" along with FileVault destroying
# disk decryption keys.
pm-hibernate() {
sudo pmset -a hibernatemode 25
sudo pmset -a standby 1
sudo pmset -a standbydelayhigh 0
sudo pmset -a standbydelaylow 0
sudo pmset -a autopoweroffdelay 0
sudo pmset -a destroyfvkeyonstandby 1
}
# Restore all settings modified by pm-hibernate to their defaults, effectively
# restoring default sleep behavior for macOS laptops.
pm-safesleep() {
sudo pmset -a hibernatemode 3
sudo pmset -a standbydelayhigh 86400
sudo pmset -a standbydelaylow 0
sudo pmset -a autopoweroffdelay 28800
sudo pmset -a destroyfvkeyonstandby 0
}
# Trigger hibernation now.
hibernate() {
pm-hibernate
sudo pmset sleepnow
}
# Trigger a safe-sleep now.
safesleep() {
pm-safesleep
sudo pmset sleepnow
}
fi

View File

@@ -40,6 +40,7 @@ alias scu="RAILS_ENV=cucumber bundle exec spring cucumber"
alias va="vagrant"
# Bundler aliases
alias bch="bundle check"
alias bcn="bundle clean"
alias bco="bundle console"
alias be="bundle exec"
@@ -50,10 +51,6 @@ alias bp="bundle package"
alias bu="bundle update"
# lazy-load rbenv
if [ -d "$HOME/.rbenv/shims" ]; then
path_prepend "$HOME/.rbenv/shims"
fi
rbenv() {
eval "$(command rbenv init -)"
rbenv "$@"

View File

@@ -2,11 +2,6 @@
# Rust environment setup.
#
# Rustup
if [ -d "$HOME/.cargo/bin" ]; then
path_prepend "$HOME/.cargo/bin"
fi
install_rust_global_packages() {
local packages=(
rls

View File

@@ -5,11 +5,6 @@ alias tmn="tm new"
alias tml="tm ls"
alias tmm="tmn -s main"
# Custom Install
if [ -d "/opt/tmux/bin" ]; then
path_prepend "/opt/tmux/bin"
fi
# Tmux Completion
if [ -f "/usr/local/etc/bash_completion.d/tmux" ]; then
source "/usr/local/etc/bash_completion.d/tmux"