1
mirror of https://github.com/jakejarvis/dotfiles.git synced 2025-09-15 23:15:30 -04:00

random updates/organization

This commit is contained in:
2021-03-14 11:35:35 -04:00
parent 3515d439b8
commit 10160f63c0
9 changed files with 169 additions and 137 deletions

View File

@@ -21,12 +21,16 @@ SAVEHIST=10000
ZSH_CUSTOM=$DOTFILES/zsh
ZSH_THEME="agnoster"
DEFAULT_USER=jake
DISABLE_UPDATE_PROMPT=true
# Oh My ZSH plugins
plugins=(
colorize
osx
history
vscode
gitignore
gnu-utils
zsh_reload
zsh-syntax-highlighting
zsh-autosuggestions
)

View File

@@ -13,103 +13,9 @@ alias ...="cd ../.."
alias ....="cd ../../.."
alias ~="cd ~"
#
# Remap macOS core utils to GNU
#
alias sed="gsed"
alias grep="ggrep"
alias find="gfind"
alias make="gmake"
alias tar="gtar"
alias which="gwhich"
alias awk="gawk"
# macOS has no `md5sum`, so use `md5` as a fallback
command -v md5sum > /dev/null || alias md5sum="md5"
# My own creation! See: https://github.com/jakejarvis/simpip
alias ipv4="curl -4 simpip.com --max-time 1 --proto-default https --silent"
alias ipv6="curl -6 simpip.com --max-time 1 --proto-default https --silent"
alias ip="ipv4; ipv6"
alias iploc="ipconfig getifaddr en0"
alias ips="ip; ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
alias dns-clear="networksetup -setdnsservers Wi-Fi"
alias dns-check="networksetup -getdnsservers Wi-Fi"
alias dns-set="networksetup -setdnsservers Wi-Fi "
alias dns-set-cloudflare="dns-set 1.1.1.1 1.0.0.1"
alias dns-set-google="dns-set 8.8.8.8 8.8.4.4"
alias flush="sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscacheutil -flushcache"
alias hosts="sudo $EDITOR /etc/hosts"
alias speed="wget -O /dev/null http://cachefly.cachefly.net/100mb.test"
alias digg="dig @1.1.1.1 +nocmd any +multiline +noall +answer"
# Update: brew, npm, gem, app store, macos
update() {
NC="\033[0m"
YELLOW="\033[0;33m"
sudo -v
echo -e "${YELLOW}Updating Homebrew formulae and casks...${NC}"
brew update
# git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow
brew upgrade
brew upgrade --cask --greedy
brew cleanup
echo -e "${YELLOW}Updating NPM/Yarn packages...${NC}"
npm install npm@latest --global
npm update --global
yarn global upgrade
echo -e "${YELLOW}Updating Ruby gems...${NC}"
gem update --system
gem update
# gem upgrade --user-install
gem cleanup
# https://stackoverflow.com/a/3452888
echo -e "${YELLOW}Updating pip packages...${NC}"
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
echo -e "${YELLOW}Updating Composer packages...${NC}"
composer global update
echo -e "${YELLOW}Updating Oh-My-ZSH...${NC}"
omz update
# echo -e "${YELLOW}Updating MAS apps...${NC}"
# mas upgrade
echo -e "${YELLOW}Updating macOS system...${NC}"
sudo softwareupdate -ia --include-config-data
}
alias rehide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias unhide="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias forcetrash="sudo rm -rf ~/.Trash /Volumes/*/.Trashes"
alias unq="sudo xattr -rd com.apple.quarantine"
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
alias gpu="system_profiler SPDisplaysDataType"
alias cpu="sysctl -n machdep.cpu.brand_string"
alias screenfetch="neofetch"
alias ripfinder="sudo killall Finder"
alias ripdock="sudo killall Dock"
alias ripmenu="sudo killall SystemUIServer NotificationCenter"
# open current directory in Finder
alias finder="open -a Finder ./"
# uncomment to use VS Code insiders build
# alias code="code-insiders"
alias vs="code ./"
alias firefox="/Applications/Firefox.app/Contents/MacOS/firefox-bin"
alias ff="firefox"
# alias speed="wget -O /dev/null http://cachefly.cachefly.net/100mb.test"
#
# Git
@@ -188,15 +94,13 @@ make_hugo() {
&& HUGO_BUILD_TAGS=extended mage -v install
)
}
alias hugo_brew="brew upgrade hugo --fetch-HEAD --build-from-source"
# run `hugo config` first to make sure we're in a Hugo directory:
alias hugo_clean="hugo config 1>/dev/null && rm -rf public/ resources/ build/"
alias sshalt="ssh -p 2222"
alias moshalt="mosh --ssh=\"ssh -p 2222\""
alias ios="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app"
alias watchos="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator\ \(Watch\).app"
alias pubkey="more ~/.ssh/id_ed25519.pub | pbcopy | echo '=> Public key copied to clipboard.'"
alias pubkey_rsa="more ~/.ssh/id_rsa.pub | pbcopy | echo '=> Public key copied to clipboard.'"

98
zsh/macos.zsh Normal file
View File

@@ -0,0 +1,98 @@
# Rosetta hacks for M1 Macs
alias intel="arch -x86_64 /bin/zsh"
alias arm="arch -arm64 /opt/homebrew/bin/zsh"
# Remap macOS core utils to GNU
alias grep="ggrep"
alias which="gwhich"
alias awk="gawk"
#alias sed="gsed"
#alias find="gfind"
#alias make="gmake"
#alias tar="gtar"
# macOS has no `md5sum`, so use `md5` as a fallback
command -v md5sum > /dev/null || alias md5sum="md5"
# My own creation! See: https://github.com/jakejarvis/simpip
alias ipv4="curl -4 simpip.com --max-time 1 --proto-default https --silent"
alias ipv6="curl -6 simpip.com --max-time 1 --proto-default https --silent"
alias ip="ipv4; ipv6"
alias iploc="ipconfig getifaddr en0"
alias ips="ip; ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
alias dns-clear="networksetup -setdnsservers Wi-Fi"
alias dns-check="networksetup -getdnsservers Wi-Fi"
alias dns-set="networksetup -setdnsservers Wi-Fi "
alias dns-set-cloudflare="dns-set 1.1.1.1 1.0.0.1"
alias dns-set-google="dns-set 8.8.8.8 8.8.4.4"
alias flush="sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscacheutil -flushcache"
# Update: brew, npm, gem, app store, macos
update() {
NC="\033[0m"
YELLOW="\033[0;33m"
echo -e "${YELLOW}Updating Homebrew formulae and casks...${NC}"
brew update
# git -C "/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask" fetch --unshallow
brew upgrade
brew upgrade --cask --greedy
brew cleanup
echo -e "${YELLOW}Updating NPM/Yarn packages...${NC}"
npm install npm@latest --global
npm update --global
yarn global upgrade
echo -e "${YELLOW}Updating Ruby gems...${NC}"
gem update --system
gem update
# gem upgrade --user-install
gem cleanup
# https://stackoverflow.com/a/3452888
echo -e "${YELLOW}Updating pip packages...${NC}"
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
echo -e "${YELLOW}Updating Composer packages...${NC}"
composer global update
echo -e "${YELLOW}Updating Oh-My-ZSH...${NC}"
omz update
echo -e "${YELLOW}Updating MAS apps...${NC}"
mas upgrade
echo -e "${YELLOW}Check for macOS system updates...${NC}"
softwareupdate --list
}
alias rehide="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias unhide="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias forcetrash="sudo rm -rf ~/.Trash /Volumes/*/.Trashes"
alias unq="sudo xattr -rd com.apple.quarantine"
alias verify_sign="codesign --verify --deep --verbose"
alias afk="/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend"
alias gpu="system_profiler SPDisplaysDataType"
alias cpu="sysctl -n machdep.cpu.brand_string"
alias screenfetch="neofetch"
alias ripfinder="sudo killall Finder"
alias ripdock="sudo killall Dock"
alias ripmenu="sudo killall SystemUIServer NotificationCenter"
# open current directory in Finder
alias finder="open -a Finder ./"
# uncomment to use VS Code insiders build
# alias code="code-insiders"
alias vs="code ./"
# Xcode simulators
alias ios="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app"
alias watchos="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator\ \(Watch\).app"
alias firefox="/Applications/Firefox.app/Contents/MacOS/firefox-bin"
alias ff="firefox"

View File

@@ -17,9 +17,18 @@ export PATH="$GOPATH/bin:$PATH"
# Ruby
export RUBY_HOME="/opt/homebrew/opt/ruby/bin"
export GEM_PATH="$HOME/.gem/ruby/3.0.0"
export GEM_PATH="/opt/homebrew/lib/ruby/gems/3.0.0/bin"
export PATH="$RUBY_HOME:$PATH"
export PATH="$GEM_PATH/bin:$PATH"
export PATH="$GEM_PATH:$PATH"
# rbenv
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml)"
if command -v rbenv 1>/dev/null 2>&1; then
eval "$(rbenv init -)"
fi
# Python
export PATH="$HOME/Library/Python/3.9/bin:$PATH"
# openjdk
export PATH="/opt/homebrew/opt/openjdk/bin:$PATH"
@@ -53,11 +62,6 @@ if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
# rbenv
if command -v rbenv 1>/dev/null 2>&1; then
eval "$(rbenv init -)"
fi
# ----- Third-party additions below: -----
# Google Cloud SDK

10
zsh/rosetta.zsh Normal file
View File

@@ -0,0 +1,10 @@
# Set iTerm color scheme to Intel blue when session running via Rosetta2
# https://cutecoder.org/software/detecting-apple-silicon-shell-script/
if [[ "$(uname -m)" == "x86_64" && "$(sysctl -in sysctl.proc_translated)" == "1" ]]; then
ARCH_BG="003862" # Intel-ish blue
else
ARCH_BG="0B0B0B" # boring black
fi
# https://iterm2.com/documentation-escape-codes.html
echo -ne "\033]1337;SetColors=bg=${ARCH_BG}\007"