From bab66d06a503797f1c33d1647fe145863afd5192 Mon Sep 17 00:00:00 2001 From: Jake Jarvis Date: Thu, 26 Jan 2023 10:06:04 -0500 Subject: [PATCH] support all debian-based machines, not just codespaces --- .gitignore | 1 - Brewfile | 217 ++++++++++++++++--------------- README.md | 2 +- codespaces/codespaces.sh | 54 -------- git/.gitconfig | 11 ++ install.sh | 50 +++++-- linux/linux.sh | 65 +++++++++ macos/defaults.sh | 2 +- macos/macos.sh | 17 +-- nano/brew.nanorc | 32 +++++ nano/{.nanorc => default.nanorc} | 2 +- starship/config.toml | 17 ++- zsh/.zprofile | 1 + zsh/.zshrc | 9 +- zsh/custom/aliases.zsh | 65 ++++----- zsh/custom/common.zsh | 12 +- zsh/custom/env.zsh | 2 + zsh/custom/functions.zsh | 2 + zsh/custom/macos.zsh | 48 ++++--- zsh/custom/path.zsh | 91 ++++++++----- zsh/custom/plugins.zsh | 122 ++++++++++++----- 21 files changed, 505 insertions(+), 317 deletions(-) delete mode 100755 codespaces/codespaces.sh create mode 100755 linux/linux.sh create mode 100644 nano/brew.nanorc rename nano/{.nanorc => default.nanorc} (95%) diff --git a/.gitignore b/.gitignore index d5ea349..387d1be 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ **/.ssh/known_hosts* *id_rsa* *id_ed25519* -**/*.local* diff --git a/Brewfile b/Brewfile index ba001f1..a158d81 100644 --- a/Brewfile +++ b/Brewfile @@ -1,51 +1,76 @@ +############################### +# Taps # +############################### +tap "1password/tap" +tap "dart-lang/dart" +tap "hashicorp/tap" +tap "homebrew/aliases" +tap "homebrew/autoupdate" +tap "homebrew/bundle" +tap "homebrew/cask" +tap "homebrew/cask-drivers" +tap "homebrew/cask-fonts" +tap "homebrew/cask-versions" +tap "homebrew/core" +tap "homebrew/services" +tap "ngrok/ngrok" +tap "planetscale/tap" +tap "sass/sass" +tap "sidneys/homebrew" + ############################### # Binaries # ############################### # Perhaps most importantly... -brew "zsh" +brew "zsh" unless OS.linux? # Better bash as a backup -brew "bash" +brew "bash" unless OS.linux? # GNU utilities (those that come with macOS are outdated) brew "coreutils" -brew "moreutils" brew "findutils" -brew "gnutls" brew "gnu-indent" brew "gnu-sed" brew "gnu-tar" -brew "gnu-indent" brew "gnu-which" - -# wget with IRI support -brew "wget" #, args: ["with-iri"] - -# GnuPG to enable PGP-signing commits brew "gnupg" - -# More recent versions of some macOS tools -brew "vim" #, args: ["with-override-system-vi"] -brew "gcc" +brew "gnutls" brew "grep" brew "make" +brew "moreutils" + +# More recent versions of some macOS tools +brew "curl", link: true +brew "gcc" +brew "gmp" brew "nano" brew "openssh" brew "screen" -brew "gmp" -brew "curl", link: true +brew "unzip", link: true +brew "vim" #, args: ["with-override-system-vi"] # Other useful binaries brew "ack" -brew "imagemagick" #, args: ["with-webp"] +brew "autoconf" +brew "automake" brew "ffmpeg" #, args: ["with-libvpx"] +brew "imagemagick" #, args: ["with-webp"] +brew "jemalloc" brew "less" +brew "libsass", args: ["HEAD"] +brew "libyaml" brew "mtr" +brew "openssl@1.1" if OS.mac? brew "p7zip" -brew "rename" +brew "pkg-config" +brew "readline" +brew "sidneys/homebrew/unrar" if OS.mac? brew "ssh-copy-id", link: true +brew "tmux" brew "tree" +brew "wget" #, args: ["with-iri"] # Git brew "git" @@ -53,126 +78,107 @@ brew "git-lfs" brew "gh" # Mostly ordinary binaries -brew "1password/tap/1password-cli" -brew "aws-shell" -brew "awscli" +brew "1password/tap/1password-cli" if OS.mac? brew "angular-cli" brew "asciinema" -brew "autoconf" -brew "automake" -brew "azure-cli" +brew "aws-shell" +brew "awscli" brew "carthage" -brew "certbot" -brew "cloudflare/cloudflare/cloudflared" brew "cocoapods" brew "composer" brew "dart-lang/dart/dart" brew "deno" brew "doctl" -brew "elixir" -brew "erlang" +brew "fx" brew "go" brew "guetzli" -brew "heroku/brew/heroku" -brew "heroku/brew/heroku-node" +brew "hashicorp/tap/packer" +brew "hashicorp/tap/terraform" +brew "hashicorp/tap/vault" brew "htop" brew "httpie" +brew "httrack" brew "hugo", args: ["HEAD"] -brew "hydra" +brew "ipinfo-cli" brew "iproute2mac" brew "jq" -brew "libsass", args: ["HEAD"] -brew "mas" +brew "mariadb" +brew "mas" if OS.mac? brew "mhash" brew "mkcert" -brew "mariadb" brew "mysql-client" brew "ncurses" +brew "neofetch" brew "netcat" +brew "openjdk" brew "openvpn" brew "optipng" brew "pandoc" brew "php" -brew "pkg-config" brew "planetscale/tap/pscale" -brew "pngcheck" brew "pngcrush" brew "postgresql" -brew "python@3" -brew "python" -brew "pyenv" +brew "protobuf" +brew "pyenv" unless OS.linux? +# brew "python" +# brew "python@3" brew "qemu" -# brew "ruby" -brew "ruby-build" -brew "rust" -brew "rbenv" +brew "rbenv" unless OS.linux? brew "rclone" +brew "rlwrap" +brew "ruby-build" unless OS.linux? +# brew "ruby" +brew "rust" brew "s3cmd" -brew "sass/sass/migrator" +brew "sass/sass/dart-sass-embedded" brew "sass/sass/sass" brew "serverless" brew "shellcheck" +brew "shfmt" brew "sqlite" -brew "sub2srt" +brew "subversion" brew "svn" brew "tor" brew "torsocks" -brew "volta" +brew "volta" unless OS.linux? brew "whois", link: true brew "wireguard-tools" -brew "wireguard-go" brew "wp-cli" brew "xz" # brew "youtube-dl" -brew "yt-dlp" brew "yq" +brew "yt-dlp" brew "zopfli" -# Android SDK -# cask "android-platform-tools" -# brew "ant" -# brew "maven" -# brew "gradle" -# cask "android-sdk" -# cask "android-ndk" - # Pentesting tools brew "aircrack-ng" -# brew "apktool" -brew "bfg" +brew "apktool" +brew "bettercap" brew "binutils" brew "binwalk" -brew "cifer" -brew "dex2jar" -brew "dns2tcp" +brew "dnsx" brew "fcrackzip" -brew "foremost" -brew "hashpump" +brew "geoip" +brew "hashcat" +brew "httpx" brew "hydra" brew "john" brew "knock" brew "massdns" brew "mitmproxy" -brew "netpbm" +brew "naabu" +brew "nikto" brew "nmap" +brew "nuclei" brew "pdfcrack" brew "pngcheck" -brew "socat" brew "sqlmap" +brew "subfinder" +brew "tcpdump" brew "tcpflow" brew "tcpreplay" brew "tcptrace" -brew "xpdf" -brew "bettercap" -brew "hashcat" -brew "nikto" -brew "tcpdump" -# brew "wpscanteam/tap/wpscan" -brew "dnsx" -brew "httpx" -brew "naabu" -brew "nuclei" -brew "subfinder" +brew "vbindiff" ############################### # macOS Apps via Cask # @@ -181,10 +187,11 @@ brew "subfinder" cask_args appdir: "/Applications" # System Utilities +cask "airbuddy" cask "appcleaner" cask "backblaze" -cask "backblaze-downloader" cask "carbon-copy-cloner" +cask "cleanmymac" cask "coconutbattery" cask "daisydisk" cask "dropbox" @@ -201,24 +208,27 @@ cask "1password" cask "authy" cask "gpg-suite" cask "little-snitch" -cask "tor-browser" +cask "tailscale" cask "tunnelblick" +cask "yubico-authenticator" +cask "yubico-yubikey-manager" # Development/Work cask "adobe-creative-cloud" -cask "adoptopenjdk/openjdk/adoptopenjdk" +cask "android-platform-tools", args: { appdir: "~/Applications" } cask "chromedriver" cask "eclipse-java" cask "github" -cask "google-cloud-sdk" +cask "google-cloud-sdk", args: { appdir: "~/Applications" } cask "imageoptim" cask "iterm2" cask "jetbrains-toolbox" cask "microsoft-office" -cask "powershell" +cask "ngrok/ngrok/ngrok" cask "sequel-pro" cask "sketch" -cask "tower" +cask "tableplus" +cask "thunderbird" cask "transmit" cask "visual-studio-code" @@ -226,15 +236,13 @@ cask "visual-studio-code" cask "docker" cask "parallels" # cask "virtualbox" -# cask "virtualbox-extension-pack" -cask "homebrew/cask-versions/virtualbox-beta" # supports M1! -# cask "vagrant" -# cask "vmware-fusion" +cask "virtualbox-beta" # supports M1! # Media cask "beamer" cask "handbrake" cask "iina" +cask "obs" cask "plex-media-player" cask "pocket-casts" cask "spotify" @@ -255,16 +263,12 @@ cask "metasploit" cask "wifi-explorer" cask "wireshark" -# Browsers (for reference only -- install these via offline DMGs no matter what) -# * Firefox -# - Stable -# - Dev: https://www.mozilla.org/en-US/firefox/developer/ -# - Nightly: https://www.mozilla.org/en-US/firefox/channel/desktop/ -# * Chrome -# - Stable -# - Canary: https://www.google.com/chrome/canary/ -# * Safari -# - Preview: https://developer.apple.com/safari/technology-preview/ +# Browsers +cask "firefox" +cask "firefox-developer-edition" +cask "google-chrome" +cask "safari-technology-preview" +cask "tor-browser" ############################### # Drivers # @@ -272,6 +276,8 @@ cask "wireshark" cask "homebrew/cask-drivers/hp-easy-start" cask "homebrew/cask-drivers/logitech-camera-settings" +cask "homebrew/cask-drivers/logi-options-plus" +cask "homebrew/cask-drivers/logitech-unifying" cask "homebrew/cask-drivers/razer-synapse" cask "homebrew/cask-drivers/sonos" @@ -281,20 +287,20 @@ cask "homebrew/cask-drivers/sonos" # Monospace cask "homebrew/cask-fonts/font-cascadia-code" -cask "homebrew/cask-fonts/font-source-code-pro" cask "homebrew/cask-fonts/font-hack" cask "homebrew/cask-fonts/font-ibm-plex-mono" cask "homebrew/cask-fonts/font-roboto-mono" -cask "homebrew/cask-fonts/font-sf-mono" # iTerm/VS Code font, comes in .pkg +cask "homebrew/cask-fonts/font-sf-mono" cask "homebrew/cask-fonts/font-sf-mono-for-powerline" +cask "homebrew/cask-fonts/font-source-code-pro" # Sans/Serif cask "homebrew/cask-fonts/font-comic-neue" cask "homebrew/cask-fonts/font-inter" -cask "homebrew/cask-fonts/font-roboto" cask "homebrew/cask-fonts/font-open-sans" -cask "homebrew/cask-fonts/font-sf-compact" # comes in .pkg -cask "homebrew/cask-fonts/font-sf-pro" # comes in .pkg +cask "homebrew/cask-fonts/font-roboto" +cask "homebrew/cask-fonts/font-sf-compact" +cask "homebrew/cask-fonts/font-sf-pro" ############################### # macOS Apps via App Store # @@ -312,16 +318,19 @@ mas "Logic Pro", id: 634148309 mas "Motion", id: 434290957 mas "Numbers", id: 409203825 mas "Pages", id: 409201541 -mas "Playgrounds", id: 1496833156 +mas "TestFlight", id: 899247664 mas "Transporter", id: 1450874784 mas "Xcode", id: 497799835 # Third Party +mas "1Blocker", id: 1365531024 +mas "1Password for Safari", id: 1569813296 mas "Amphetamine", id: 937984704 -mas "Disk Speed Test", id: 425264550 +mas "Drafts", id: 1435957248 +mas "Magnet", id: 441258766 mas "Microsoft Remote Desktop", id: 1295203466 mas "Shazam", id: 897118787 mas "Silicon Info", id: 1542271266 -mas "Twitter", id: 409789998 +mas "Speedtest", id: 1153157709 mas "VMware Remote Console", id: 1230249825 mas "WireGuard", id: 1451685025 diff --git a/README.md b/README.md index 3c5ea29..f00d83e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ All of the juicy stuff you're probably looking for is at: ## Usage -Designed for macOS, kinda works on Linux (requires [ZSH to be installed](https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH#ubuntu-debian--derivatives-windows-10-wsl--native-linux-kernel-with-windows-10-build-1903) first): +Designed for macOS, also works on Linux (specifially Debian and Ubuntu): ```bash git clone https://github.com/jakejarvis/dotfiles.git ~/.dotfiles diff --git a/codespaces/codespaces.sh b/codespaces/codespaces.sh deleted file mode 100755 index bb969a6..0000000 --- a/codespaces/codespaces.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash - -set -e - -# link automatically cloned dotfiles repo to regular ~/.dotfiles path -# https://docs.github.com/en/codespaces/troubleshooting/troubleshooting-personalization-for-codespaces#troubleshooting-dotfiles -ln -sf /workspaces/.codespaces/.persistedshare/dotfiles ~/.dotfiles - -# clean up -sudo rm -rf /var/lib/apt/lists/* - -# extra ubuntu packages -if [[ "$(sudo find /var/lib/apt/lists/* | wc -l)" = "0" ]]; then - sudo apt-get update - sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ - man \ - curl \ - wget \ - lsb-release \ - ca-certificates \ - file \ - shared-mime-info -fi - -# prepare zinit manually -ZINIT_HOME="$HOME/.local/share/zinit/zinit.git" -if [[ ! -d "$ZINIT_HOME" ]]; then - mkdir -p "$(dirname "$ZINIT_HOME")" - git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" -fi - -# install volta -if ! command -v volta &>/dev/null; then - export VOLTA_HOME="$HOME/.volta" - export PATH="$VOLTA_HOME/bin:$PATH" - curl -fsSL https://get.volta.sh | bash -s -- --skip-setup -fi -volta install node@lts npm@latest yarn@latest - -# install rbenv & ruby-build -if ! command -v rbenv &>/dev/null; then - curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash -fi - -# install pyenv -if ! command -v pyenv &>/dev/null; then - curl -fsSL https://github.com/pyenv/pyenv-installer/raw/HEAD/bin/pyenv-installer | bash -fi - -# set shell to zsh -sudo chsh -s /bin/zsh "$(whoami)" - -# clean up -sudo rm -rf /var/lib/apt/lists/* diff --git a/git/.gitconfig b/git/.gitconfig index 7a7325f..18bf626 100644 --- a/git/.gitconfig +++ b/git/.gitconfig @@ -1,5 +1,6 @@ [core] editor = code --wait + pager = delta excludesfile = ~/.gitignore_global # Make `git rebase` safer on macOS @@ -25,6 +26,8 @@ tool = default-difftool [difftool "default-difftool"] cmd = code --wait --diff $LOCAL $REMOTE +[interactive] + diffFilter = delta --color-only --features=interactive [alias] undo = reset --soft HEAD~1 pom = push origin main @@ -53,3 +56,11 @@ keepBackup = true [color] ui = auto +[delta] + features = decorations +[delta "interactive"] + keep-plus-minus-markers = false +[delta "decorations"] + hunk-header-style = omit + line-numbers = true + syntax-theme = base16 diff --git a/install.sh b/install.sh index a78f021..90b05e0 100755 --- a/install.sh +++ b/install.sh @@ -1,19 +1,23 @@ #!/usr/bin/env bash -set -euo pipefail +set -e echo "🙏 Deep breaths, everything will (probably) be fine!" echo "" # location of the *full repo* (defaults to ~/.dotfiles) DOTFILES_PATH="${DOTFILES_PATH:="$HOME/.dotfiles"}" +# location of this script (should be right next to all the other files, but we handle that next if it's not) +INSTALLER_PATH="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" -# override location when running on GitHub Codespaces since it's cloned automatically: +# if this is a codespace, link automatically cloned dotfiles repo to the expected DOTFILES_PATH # https://docs.github.com/en/codespaces/troubleshooting/troubleshooting-personalization-for-codespaces#troubleshooting-dotfiles -if [[ "$CODESPACES" = "true" ]]; then - DOTFILES_PATH="/workspaces/.codespaces/.persistedshare/dotfiles" -elif [[ ! -f "README.md" ]]; then - # clone this repo if this script is all by its lonesome +if [[ "$CODESPACES" = "true" ]] && [[ -d /workspaces/.codespaces/.persistedshare/dotfiles ]]; then + ln -sf /workspaces/.codespaces/.persistedshare/dotfiles "$DOTFILES_PATH" +fi + +# clone this repo if this script is all by itself and/or we're not in the expected location +if [[ "$INSTALLER_PATH" != "$DOTFILES_PATH" ]] && [[ ! -d "$DOTFILES_PATH" ]]; then git clone https://github.com/jakejarvis/dotfiles.git "$DOTFILES_PATH" echo "Successfully cloned the full repo to '$DOTFILES_PATH'" @@ -29,24 +33,44 @@ ln -sf "$DOTFILES_PATH/zsh/.zshrc" ~/.zshrc ln -sf "$DOTFILES_PATH/zsh/.zprofile" ~/.zprofile ln -sf "$DOTFILES_PATH/git/.gitconfig" ~/.gitconfig ln -sf "$DOTFILES_PATH/git/.gitignore_global" ~/.gitignore_global -ln -sf "$DOTFILES_PATH/nano/.nanorc" ~/.nanorc ln -sf "$DOTFILES_PATH/starship/config.toml" ~/.config/starship.toml -if [[ "$(uname)" = "Darwin" ]]; then - # suppress terminal login banners - touch ~/.hushlogin +# this file will be sourced by .zshrc for more sensitive variables/settings +touch ~/.zshrc.local +# prepare zinit manually +ZINIT_HOME="$HOME/.local/share/zinit/zinit.git" +if [[ ! -d "$ZINIT_HOME" ]]; then + mkdir -p "$(dirname "$ZINIT_HOME")" + git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" +fi + +# the remainder of the setup tasks are OS-specific +if [[ "$OSTYPE" = "darwin"* ]]; then # final symlinks if [[ ! -d ~/.ssh ]]; then mkdir -p ~/.ssh && chmod 700 ~/.ssh fi ln -sf "$DOTFILES_PATH/ssh/.ssh/config" ~/.ssh/config + ln -sf "$DOTFILES_PATH/nano/brew.nanorc" ~/.nanorc + ln -sf "$DOTFILES_PATH/Brewfile" ~/Brewfile + + # suppress terminal login banners + touch ~/.hushlogin # shellcheck disable=SC1090,SC1091 source "$DOTFILES_PATH/macos/macos.sh" -elif [[ "$CODESPACES" = "true" ]]; then +elif [[ "$OSTYPE" = "linux-gnu"* ]]; then + # final symlinks + ln -sf "$DOTFILES_PATH/nano/default.nanorc" ~/.nanorc + # shellcheck disable=SC1090,SC1091 - source "$DOTFILES_PATH/codespaces/codespaces.sh" + source "$DOTFILES_PATH/linux/linux.sh" +else + echo "I don't recognize this OS... skipping extra steps." fi -echo "🎉 Done!" +# wow +echo "" +echo "🎉 It actually worked!" +echo "Log out and log back in (or just restart) to finish installing all ZSH features." diff --git a/linux/linux.sh b/linux/linux.sh new file mode 100755 index 0000000..56bccb6 --- /dev/null +++ b/linux/linux.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +set -e + +if [[ -e /etc/debian_version ]]; then + sudo apt-get update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + zsh \ + zsh-common \ + zsh-doc \ + man \ + curl \ + wget \ + gnupg \ + apt-transport-https \ + ca-certificates \ + lsb-release \ + tzdata \ + shared-mime-info \ + build-essential \ + file \ + procps \ + git + + sudo apt-get clean -y +fi + +# set machine's timezone to local time +sudo timedatectl set-timezone America/New_York + +# install linuxbrew: +# https://docs.brew.sh/Homebrew-on-Linux#install +if ! command -v brew &>/dev/null; then + # TODO: hack to permit installing as root, find a better way + # https://github.com/Homebrew/install/blob/master/install.sh#L306 + sudo touch /.dockerenv + curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash + sudo rm /.dockerenv +fi + +# install tailscale +if ! command -v tailscale &>/dev/null; then + curl -fsSL https://tailscale.com/install.sh | bash +fi + +# install volta +if ! command -v volta &>/dev/null; then + export VOLTA_HOME="$HOME/.volta" + export PATH="$VOLTA_HOME/bin:$PATH" + curl -fsSL https://get.volta.sh | bash -s -- --skip-setup +fi +volta install node@lts npm@latest yarn@latest + +# install rbenv & ruby-build +if ! command -v rbenv &>/dev/null; then + curl -fsSL https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-installer | bash +fi + +# install pyenv +if ! command -v pyenv &>/dev/null; then + curl -fsSL https://github.com/pyenv/pyenv-installer/raw/HEAD/bin/pyenv-installer | bash +fi + +# set login shell to zsh +sudo chsh -s "$(which zsh)" "$(whoami)" diff --git a/macos/defaults.sh b/macos/defaults.sh index 003087f..d1a5e8d 100755 --- a/macos/defaults.sh +++ b/macos/defaults.sh @@ -6,7 +6,7 @@ # https://github.com/paulirish/dotfiles/blob/master/.osx # https://github.com/kevinSuttle/macOS-Defaults/blob/master/.macos -set -euo pipefail +set -e # Change new hostname here if necessary COMPUTER_NAME="JJ-MBA" diff --git a/macos/macos.sh b/macos/macos.sh index 5942f72..fbba043 100755 --- a/macos/macos.sh +++ b/macos/macos.sh @@ -1,12 +1,6 @@ #!/usr/bin/env bash -set -euo pipefail - -# This shouldn't be run if not on macOS, but make double sure -if [[ ! "$(uname)" = "Darwin" ]]; then - echo "Skipping macOS steps." - return -fi +set -e # Ask for the administrator password upfront sudo -v @@ -24,8 +18,8 @@ sudo xcodebuild -license accept # This whole thing kinda hinges on having Homebrew... # Check for it and install from GitHub if it's not there -if [[ ! "$(which brew)" ]]; then - /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" +if ! command -v brew &>/dev/null; then + curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash fi # Disable analytics @@ -45,11 +39,6 @@ chsh -s "$(brew --prefix)/bin/zsh" chmod 755 "$(brew --prefix)/share/zsh" chmod 755 "$(brew --prefix)/share/zsh/site-functions" -# install zinit -ZINIT_HOME="$HOME/.local/share/zinit/zinit.git" -mkdir -p "$(dirname "$ZINIT_HOME")" -git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" - # 1Password SSH integration # https://developer.1password.com/docs/ssh/get-started#step-4-configure-your-ssh-or-git-client mkdir -p ~/.1password diff --git a/nano/brew.nanorc b/nano/brew.nanorc new file mode 100644 index 0000000..6084fab --- /dev/null +++ b/nano/brew.nanorc @@ -0,0 +1,32 @@ +# Enable built-in syntax highlighting +# IMPORTANT: this path is specific to homebrew's nano, hence this duplicate rc file only for macOS, which AFAIK is the +# best way to do this... +include "/opt/homebrew/Cellar/nano/*/share/nano/*.nanorc" + +# Non-default settings +set historylog # Save the last 100 history searches for later use. +# set positionlog # Saves the cursor position between editing sessions. +set zap # Allows you to highlight text (CTRL+SHIFT+ARROW) and delete it with backspace. +set afterends # Ctrl+Right moves to end of word instead of beginning. +set wordchars "_" # Recognize _ as part of a word. +set autoindent # A new line will have the same number of tabs/leading spaces as the previous one. +# set tabsize 2 +# set tabstospaces + +# Fix option+left/right word skipping +# https://unix.stackexchange.com/a/392309 +unbind M-B all +unbind M-F all +bind M-B prevword main +bind M-F nextword main + +# Muscle memory adaptations +bind ^s writeout main # Ctrl+S for save. +bind ^f whereis main # Ctrl+F for search. +# bind ^h replace main # Ctrl+H for find/replace. +bind ^z undo main # Ctrl+Z for undo. +# bind ^y redo main # Ctrl+Y for redo. +# bind ^x cut main # Ctrl+X for cut. +# bind ^c copy main # Ctrl+C for copy. +# bind ^v paste all # Ctrl+V for paste. +bind ^/ comment main # Ctrl+/ for (un)commenting current line. diff --git a/nano/.nanorc b/nano/default.nanorc similarity index 95% rename from nano/.nanorc rename to nano/default.nanorc index e8c5979..1f47888 100644 --- a/nano/.nanorc +++ b/nano/default.nanorc @@ -1,5 +1,5 @@ # Enable built-in syntax highlighting -# include "/opt/homebrew/Cellar/nano/*/share/nano/*.nanorc" +include "/usr/share/nano/*.nanorc" # Non-default settings set historylog # Save the last 100 history searches for later use. diff --git a/starship/config.toml b/starship/config.toml index 75d1503..4b72987 100644 --- a/starship/config.toml +++ b/starship/config.toml @@ -1,5 +1,5 @@ # https://starship.rs/config/ -"$schema" = 'https://starship.rs/config-schema.json' +"$schema" = "https://starship.rs/config-schema.json" # A minimal left prompt: # format = """$character""" @@ -46,11 +46,11 @@ symbol = " " [git_commit] tag_symbol = " " tag_disabled = false -format = '[ $hash$tag]($style) ' +format = "[ $hash$tag]($style) " [git_status] style = "bold bright-yellow" -format = '([ $all_status$ahead_behind]($style) )' +format = "([ $all_status$ahead_behind]($style) )" ignore_submodules = true renamed = "" deleted = "" @@ -59,6 +59,12 @@ stashed = "" [golang] symbol = " " +[hostname] +ssh_only = true +ssh_symbol = " " +style = "bold green" +format = "[$ssh_symbol$hostname]($style) " + [localip] disabled = true @@ -101,5 +107,10 @@ symbol = " " [rust] symbol = " " +[username] +format = "[ $user]($style) " +style_root = "bold bright-red" +style_user = "bold bright-red" + [vagrant] disabled = true diff --git a/zsh/.zprofile b/zsh/.zprofile index e69de29..80a6663 100644 --- a/zsh/.zprofile +++ b/zsh/.zprofile @@ -0,0 +1 @@ +# Intentionally left blank. diff --git a/zsh/.zshrc b/zsh/.zshrc index 1629c52..6f0f60a 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -1,14 +1,21 @@ +#!/usr/bin/env zsh + # path to this directory: export ZSH_CUSTOM=~/.dotfiles/zsh # load .zsh files from the above dir in this order: -for _dotzsh in "$ZSH_CUSTOM"/custom/{common,env,path,aliases,functions,plugins,macos}.zsh; do +for _dotzsh in "$ZSH_CUSTOM"/custom/{common,env,path,aliases,functions,plugins}.zsh; do if [[ -f "$_dotzsh" ]]; then source "$_dotzsh" fi done unset _dotzsh +# macos.zsh has aliases, functions, etc specific to macOS: +if [[ "$OSTYPE" = "darwin"* ]] && [[ -f "$ZSH_CUSTOM"/custom/macos.zsh ]]; then + source "$ZSH_CUSTOM"/custom/macos.zsh +fi + if [[ -f ~/.zshrc.local ]]; then source ~/.zshrc.local fi diff --git a/zsh/custom/aliases.zsh b/zsh/custom/aliases.zsh index a365d01..72b8131 100644 --- a/zsh/custom/aliases.zsh +++ b/zsh/custom/aliases.zsh @@ -1,3 +1,5 @@ +#!/usr/bin/env zsh + # allow sudo-able aliases alias sudo="sudo " @@ -22,6 +24,7 @@ alias gpom="git push origin main" alias glom="git pull origin main" alias gpo="git push origin" # + branch name alias glo="git pull origin" # + branch name +alias glfm="git fetch && git reset origin/main --hard" alias gb="git checkout" # + existing branch name alias gbn="git checkout -b" # + new branch name alias grm="git rebase -i origin/main" @@ -65,26 +68,10 @@ alias npr="npm run" alias fresh_npm="rm -rf node_modules package-lock.json && npm install" alias fresh_yarn="rm -rf node_modules yarn.lock && yarn install" -# Hugo -# install from source -make_hugo() { - # parentheses lets us cd to Hugo path without changing our current location - ( - cd "$GOPATH/src/github.com/gohugoio/hugo" \ - && bash -c "$GOPATH/bin/hugo env" \ - && git checkout master \ - && mage uninstall \ - && git pull origin master \ - && git reset --hard HEAD \ - && mage -v hugo \ - && HUGO_BUILD_TAGS=extended mage -v install \ - && bash -c "$GOPATH/bin/hugo env" - ) -} -# install from brew -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/" +# uncomment to use VS Code insiders build +# alias code="code-insiders" +# open current working directory in VS Code +alias vs="code ." # an original creation, see https://github.com/jakejarvis/simpip alias ipv4="curl -4 simpip.com --max-time 1 --proto-default https --silent" @@ -93,19 +80,39 @@ alias ip="ipv4; ipv6" alias ip-local="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 }'" -# keys -alias pubkey="pbcopy < ~/.ssh/id_ed25519.pub && echo '=> Public key copied to clipboard.'" -alias pubkey_rsa="pbcopy < ~/.ssh/id_rsa.pub && echo '=> Public key copied to clipboard.'" - -# tailscale: https://tailscale.com/kb/1080/cli/?tab=macos -alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale" -alias tscl="tailscale" - # youtube-dl -alias youtube-dl="yt-dlp" # fork: https://github.com/yt-dlp/yt-dlp +alias youtube-dl="yt-dlp" # better youtube-dl fork: https://github.com/yt-dlp/yt-dlp alias ytdl="youtube-dl -f bestvideo+bestaudio" alias ytmp3="youtube-dl -f bestaudio -x --audio-format mp3 --audio-quality 320K" +# Hugo: build & install from source as `hugo-dev` +make_hugo() { + if [[ ! -d "$GOPATH"/src/github.com/gohugoio/hugo ]]; then + mkdir -p "$GOPATH"/src/github.com/gohugoio/hugo + git clone https://github.com/gohugoio/hugo.git "$GOPATH"/src/github.com/gohugoio/hugo + fi + + if ! command -v mage &>/dev/null; then + go install github.com/magefile/mage@latest + fi + + # parentheses lets us cd to Hugo path without changing our current location + ( + cd "$GOPATH"/src/github.com/gohugoio/hugo \ + && "$GOPATH"/bin/hugo-dev env 2>/dev/null || true \ + && git checkout master \ + && mage uninstall \ + && git pull origin master \ + && git reset --hard HEAD \ + && mage -v hugo \ + && HUGO_BUILD_TAGS=extended mage -v install \ + && mv -fv "$GOPATH"/bin/hugo "$GOPATH"/bin/hugo-dev \ + && "$GOPATH"/bin/hugo-dev env + ) +} +# 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/" + # misc. alias screenfetch="neofetch" alias weather="curl 'https://wttr.in/?format=v2'" diff --git a/zsh/custom/common.zsh b/zsh/custom/common.zsh index bc6a0c2..8800645 100644 --- a/zsh/custom/common.zsh +++ b/zsh/custom/common.zsh @@ -1,10 +1,18 @@ +#!/usr/bin/env zsh + autoload -U colors && colors autoload -Uz url-quote-magic zle -N self-insert url-quote-magic autoload -Uz select-word-style -select-word-style shell +select-word-style bash + +# enable bash-like 'help' command for zsh: +# https://stackoverflow.com/questions/4405382/how-can-i-read-documentation-about-built-in-zsh-commands +unalias run-help 2>/dev/null +autoload run-help +alias help=run-help # --- @@ -42,7 +50,7 @@ export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}" -export HISTFILE=~/.zsh_history +export HISTFILE="${HISTFILE:-$HOME/.zsh_history}" export HISTSIZE=10000 export SAVEHIST=10000 diff --git a/zsh/custom/env.zsh b/zsh/custom/env.zsh index 24e3243..53a5158 100644 --- a/zsh/custom/env.zsh +++ b/zsh/custom/env.zsh @@ -1,3 +1,5 @@ +#!/usr/bin/env zsh + export HOMEBREW_NO_ANALYTICS=1 export HOMEBREW_NO_INSECURE_REDIRECT=1 # export HOMEBREW_CASK_OPTS=--require-sha diff --git a/zsh/custom/functions.zsh b/zsh/custom/functions.zsh index c0ef733..de2ff0c 100644 --- a/zsh/custom/functions.zsh +++ b/zsh/custom/functions.zsh @@ -1,3 +1,5 @@ +#!/usr/bin/env zsh + # Make a new directory and `cd` right into it (this seems like a no-brainer) mkcd() { mkdir -p -- "$1" && diff --git a/zsh/custom/macos.zsh b/zsh/custom/macos.zsh index c0c7e2d..67bd8c4 100644 --- a/zsh/custom/macos.zsh +++ b/zsh/custom/macos.zsh @@ -1,27 +1,17 @@ -# all of this is only for macOS -if [[ ! "$(uname)" = "Darwin" ]]; then - return -fi +#!/usr/bin/env zsh -# export BROWSER="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" export BROWSER="/Applications/Firefox.app/Contents/MacOS/firefox" +# export BROWSER="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" # Rosetta hacks for M1 alias intel="arch -x86_64 /bin/zsh" alias arm="arch -arm64 zsh" -# check & install updates for: -# - brew -# - node/npm -# - ruby/gems -# - pip -# - app store -# - macos -# - zinit system_update() { - NC="\033[0m" - YELLOW="\033[0;33m" + local NC="\033[0m" + local YELLOW="\033[0;33m" + # homebrew echo -e "${YELLOW}Updating Homebrew formulae and casks...${NC}" brew update brew upgrade @@ -30,13 +20,15 @@ system_update() { brew upgrade $(brew outdated --greedy --verbose | awk '$2 !~ /(latest)/ {print $1}') brew cleanup + # node, npm, yarn echo -e "${YELLOW}Updating global NPM/Yarn packages...${NC}" - volta fetch node@latest + volta fetch node@latest # pull latest non-LTS version but don't use it volta install node@lts volta install yarn@1 volta run --node lts --no-yarn -- npm update --global volta run --node lts --yarn 1 -- yarn global upgrade + # ruby, gems echo -e "${YELLOW}Updating Ruby and gems...${NC}" CONFIGURE_OPTS="$RUBY_CONFIGURE_OPTS" \ rbenv install --skip-existing "$(rbenv install -l | grep -v - | tail -1)" && \ @@ -46,16 +38,20 @@ system_update() { gem cleanup rbenv rehash + # pips # https://stackoverflow.com/a/3452888 echo -e "${YELLOW}Updating pip packages...${NC}" pip3 list --outdated --format=json | jq -r '.[] | .name+"="+.latest_version' | cut -d = -f 1 | xargs -n1 pip3 install -U + # App Store echo -e "${YELLOW}Checking for App Store updates...${NC}" mas outdated + # macOS system echo -e "${YELLOW}Checking for macOS system updates...${NC}" softwareupdate --list + # zinit & plugins echo -e "${YELLOW}Updating zinit...${NC}" zinit self-update zinit update --all @@ -63,9 +59,8 @@ system_update() { 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 force_empty="sudo rm -rf ~/.Trash /Volumes/*/.Trashes" alias unq="sudo xattr -rd com.apple.quarantine" -alias verify_sign="codesign --verify --deep --verbose" alias gpu="system_profiler SPDisplaysDataType" alias cpu="sysctl -n machdep.cpu.brand_string" @@ -84,13 +79,14 @@ 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" -# 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 ios_sim="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" +alias watchos_sim="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator\ \(Watch\).app" -alias firefox="/Applications/Firefox.app/Contents/MacOS/firefox-bin" -alias ff="firefox" +# convenient access to public key +alias pubkey="pbcopy < ~/.ssh/id_ed25519.pub && echo '=> Public key copied to clipboard.'" +alias pubkey_rsa="pbcopy < ~/.ssh/id_rsa.pub && echo '=> Public key copied to clipboard.'" + +# workaround for lack of tailscale CLI on mac: +# https://tailscale.com/kb/1080/cli/?tab=macos#using-the-cli +alias tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale" diff --git a/zsh/custom/path.zsh b/zsh/custom/path.zsh index d9752e9..674862a 100644 --- a/zsh/custom/path.zsh +++ b/zsh/custom/path.zsh @@ -1,49 +1,76 @@ -# a lot of this file only applies to macOS -if [[ "$(uname)" = "Darwin" ]]; then - # set PATH, MANPATH, etc., for Homebrew - eval "$(/opt/homebrew/bin/brew shellenv)" +#!/usr/bin/env zsh +# set PATH, MANPATH, etc., for Homebrew +if [[ -x /opt/homebrew/bin/brew ]]; then + # macOS on Apple Silicon + eval "$(/opt/homebrew/bin/brew shellenv)" +elif [[ -x /usr/local/bin/brew ]]; then + # macOS on x86 + eval "$(/opt/homebrew/bin/brew shellenv)" +elif [[ -d /home/linuxbrew/.linuxbrew ]]; then + # Linux, system install + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" +elif [[ -d "$HOME/.linuxbrew" ]]; then + # Linux, user install + eval "$("$HOME/.linuxbrew/bin/brew" shellenv)" +fi + +# a lot of this file only applies to macOS +if [[ "$OSTYPE" = "darwin"* ]]; then # remap macOS core utils to GNU equivalents (from coreutils, findutils, gnu-*, etc.): # https://gist.github.com/skyzyx/3438280b18e4f7c490db8a2a2ca0b9da?permalink_comment_id=3049694#gistcomment-3049694 - for gbin in "$(brew --prefix)"/opt/*/libexec/gnubin; do - export PATH="$gbin:$PATH" - done - # Ensure `man` refers to the new binaries: - for gman in "$(brew --prefix)"/opt/*/libexec/gnuman; do - export MANPATH="$gman:$MANPATH" - done - unset gbin gman + if command -v brew &>/dev/null; then + for gbin in "$(brew --prefix)"/opt/*/libexec/gnubin; do + export PATH="$gbin:$PATH" + done + # Ensure `man` refers to the new binaries: + for gman in "$(brew --prefix)"/opt/*/libexec/gnuman; do + export MANPATH="$gman:$MANPATH" + done + unset gbin gman - # OpenJDK - export PATH="$HOMEBREW_PREFIX/opt/openjdk/bin:$PATH" + # shellcheck disable=SC2155 + export HELPDIR="$(brew --prefix)/share/zsh/help" - # metasploit - export PATH="/opt/metasploit-framework/bin:$PATH" + # OpenJDK + # shellcheck disable=SC2155 + export PATH="$(brew --prefix)/opt/openjdk/bin:$PATH" - # macOS-only fixes for rbenv/ruby below - # shellcheck disable=SC2155 - export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml)" + # macOS-only fixes for rbenv/ruby below + # shellcheck disable=SC2155 + export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl@1.1) --with-readline-dir=$(brew --prefix readline) --with-libyaml-dir=$(brew --prefix libyaml) --with-jemalloc-dir=$(brew --prefix jemalloc)" + + # tell compilers where to find all of this stuff + # shellcheck disable=SC2155 + export LDFLAGS="$LDFLAGS -L$(brew --prefix openssl@1.1)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix jemalloc)/lib" + # shellcheck disable=SC2155 + export CPPFLAGS="$CPPFLAGS -I$(brew --prefix openjdk)/include -I$(brew --prefix openssl@1.1)/include -I$(brew --prefix readline)/include -I$(brew --prefix jemalloc)/include" + fi fi # go -export GOPATH="$HOME/golang" -export PATH="$GOPATH/bin:$PATH" - -# rbenv -if command -v rbenv 1>/dev/null 2>&1; then - eval "$(rbenv init -)" +if [[ -d "$HOME/golang" ]]; then + export GOPATH="$HOME/golang" + export PATH="$GOPATH/bin:$PATH" fi # rust/cargo -export PATH="$HOME/.cargo/bin:$PATH" +if [[ -d "$HOME/.cargo" ]]; then + export PATH="$HOME/.cargo/bin:$PATH" +fi + +# rbenv +if command -v rbenv &>/dev/null; then + eval "$(rbenv init --no-rehash - zsh)" +fi # pyenv -export PYENV_ROOT="$HOME/.pyenv" -export PATH="$PYENV_ROOT/bin:$PATH" -if command -v pyenv 1>/dev/null 2>&1; then - eval "$(pyenv init -)" +if command -v pyenv &>/dev/null; then + eval "$(pyenv init --no-rehash - zsh)" fi # volta -export VOLTA_HOME="$HOME/.volta" -export PATH="$VOLTA_HOME/bin:$PATH" +if [[ -d "$HOME/.volta" ]]; then + export VOLTA_HOME="$HOME/.volta" + export PATH="$VOLTA_HOME/bin:$PATH" +fi diff --git a/zsh/custom/plugins.zsh b/zsh/custom/plugins.zsh index eb46f54..9e2e435 100644 --- a/zsh/custom/plugins.zsh +++ b/zsh/custom/plugins.zsh @@ -1,3 +1,5 @@ +#!/usr/bin/env zsh + # check for zinit and clone if not installed ZINIT_HOME="$HOME/.local/share/zinit/zinit.git" if [[ ! -d "$ZINIT_HOME" ]]; then @@ -57,9 +59,26 @@ zinit ice from"gh-r" as"command" \ mv -vf bat-*/bat.1 ${ZINIT[MAN_DIR]}/man1 " \ atpull"%atclone" \ - atload"alias cat='bat --paging=never --color=auto --style=\"numbers,changes\" --theme=\"Dracula\"'" + atload" + export BAT_THEME='base16' + export BAT_PAGER='less -R -F -+X --mouse' + export MANPAGER='sh -c \"col -bx | bat --color=always --style=plain --language=man\"' + alias cat='bat --paging=never --color=auto --style=numbers,changes' + alias cats='bat --paging=always --color=always --style=numbers,changes' + alias catcat='\cat --paging=never --color=auto --style=plain' + " zinit light sharkdp/bat +# grab delta binary +zinit ice from"gh-r" as"command" \ + mv"delta-*/delta -> delta" \ + dl"https://github.com/dandavison/delta/raw/HEAD/etc/completion/completion.zsh -> _delta" \ + atload" + # https://dandavison.github.io/delta/mouse-scrolling.html + export DELTA_PAGER='less -R -F -+X --mouse' + " +zinit light dandavison/delta + # grab fd binary # TODO: preview commands are an absolute sh*tshow, maybe use .lessfilter? # https://github.com/Aloxaf/fzf-tab/wiki/Preview#show-file-contents @@ -73,7 +92,7 @@ zinit ice from"gh-r" as"command" \ atpull"%atclone" \ atload' FZF_FD_OPTS="--color always --hidden --follow --exclude .git --exclude node_modules" - FZF_PREVIEW_FILE_COMMAND="bat --color=always --paging=never --style=plain --theme=Dracula" + FZF_PREVIEW_FILE_COMMAND="bat --color=always --paging=never --style=plain" FZF_PREVIEW_DIR_COMMAND="exa -1a --color=always --icons --group-directories-first" FZF_DEFAULT_OPTS="--no-mouse --bind \"tab:accept,ctrl-y:preview-page-up,ctrl-v:preview-page-down,ctrl-e:execute-silent(\${VISUAL:-code} {+} >/dev/null 2>&1)\"" FZF_DEFAULT_COMMAND="fd --type f $FZF_FD_OPTS" @@ -86,14 +105,14 @@ zinit light sharkdp/fd # grab fzf binary from release & other files from source zinit ice from"gh-r" as"command" \ - dl"https://raw.githubusercontent.com/junegunn/fzf/master/shell/key-bindings.zsh -> key-bindings.zsh" \ - dl"https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh -> _fzf" \ - dl"https://raw.githubusercontent.com/junegunn/fzf/master/man/man1/fzf.1 -> ${ZINIT[MAN_DIR]}/man1/fzf.1" \ - dl"https://raw.githubusercontent.com/junegunn/fzf/master/man/man1/fzf-tmux.1 -> ${ZINIT[MAN_DIR]}/man1/fzf-tmux.1" \ + dl"https://github.com/junegunn/fzf/raw/HEAD/shell/key-bindings.zsh -> key-bindings.zsh" \ + dl"https://github.com/junegunn/fzf/raw/HEAD/shell/completion.zsh -> _fzf" \ + dl"https://github.com/junegunn/fzf/raw/HEAD/man/man1/fzf.1 -> ${ZINIT[MAN_DIR]}/man1/fzf.1" \ + dl"https://github.com/junegunn/fzf/raw/HEAD/man/man1/fzf-tmux.1 -> ${ZINIT[MAN_DIR]}/man1/fzf-tmux.1" \ src"key-bindings.zsh" zinit light junegunn/fzf -# all the colors +# grab vivid binary (for all the colors) # https://github.com/sharkdp/vivid/tree/master/themes # shellcheck disable=SC2016 zinit ice from"gh-r" as"command" \ @@ -101,14 +120,6 @@ zinit ice from"gh-r" as"command" \ atload'export LS_COLORS="$(vivid generate snazzy)"' zinit load sharkdp/vivid -# direnv -zinit ice from"gh-r" as"command" \ - mv"direnv* -> direnv" \ - atclone"./direnv hook zsh > zhook.zsh" \ - atpull"%atclone" \ - src"zhook.zsh" -zinit light direnv/direnv - # history substring searching # only bind these keys once they're ready bindkey -r "^[[A" @@ -122,9 +133,8 @@ zinit ice wait lucid \ zinit light zsh-users/zsh-history-substring-search # tab completions via fzf -# TODO: fix git-* completions, apparently there's some conflict with brew's git -# https://github.com/Aloxaf/fzf-tab/wiki/Preview#git -zinit ice wait lucid \ +zinit ice wait"1" lucid \ + has"fzf" \ atload" zstyle ':completion:*' verbose yes zstyle ':completion:*' list-colors \${(s.:.)LS_COLORS} @@ -133,19 +143,20 @@ zinit ice wait lucid \ zstyle ':completion::complete:*:*:globbed-files' ignored-patterns '.DS_Store' 'Icon?' '.Trash' zstyle ':completion::complete:rm:*:globbed-files' ignored-patterns zstyle ':fzf-tab:*' fzf-command fzf + zstyle ':fzf-tab:*' fzf-flags '--ansi' zstyle ':fzf-tab:*' fzf-bindings \ 'tab:accept' \ 'ctrl-y:preview-page-up' \ 'ctrl-v:preview-page-down' \ - 'ctrl-e:execute-silent(${VISUAL:-code} \${realpath:-\$word} >/dev/null 2>&1)' \ - 'ctrl-w:execute(${EDITOR:-nano} \${realpath:-\$word} >/dev/tty /dev/null 2>&1)' \ + 'ctrl-w:execute(\${EDITOR:-nano} \$realpath >/dev/tty _git" \ + dl"https://github.com/git/git/raw/HEAD/contrib/completion/git-completion.bash -> git-completion.bash" \ + atpull"zinit creinstall -q ." \ + atload' + zstyle ":completion:*:*:git:*" script "$PWD/git-completion.bash" + ' \ + nocompile +zinit light zdharma-continuum/null + +# use zinit to track completions from non-zinit programs +zinit ice wait lucid blockf as"completions" \ + id-as"local-completions" \ + dl"https://github.com/docker/cli/raw/HEAD/contrib/completion/zsh/_docker -> _docker" \ + dl"https://github.com/docker/compose/raw/master/contrib/completion/zsh/_docker-compose -> _docker-compose" \ + dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_node -> _node" \ + dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_yarn -> _yarn" \ + dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_bundle -> _bundle" \ + dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_rails -> _rails" \ + dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_golang -> _golang" \ + dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_shellcheck -> _shellcheck" \ + dl"https://github.com/zsh-users/zsh-completions/raw/HEAD/src/_httpie -> _httpie" \ + dl"https://github.com/rbenv/rbenv/raw/HEAD/completions/rbenv.zsh -> _rbenv" \ + dl"https://github.com/pyenv/pyenv/raw/HEAD/completions/pyenv.zsh -> _pyenv" \ + atclone" + command -v volta &>/dev/null && volta completions zsh > _volta || true + command -v npm &>/dev/null && npm completion > _npm || true + command -v gh &>/dev/null && gh completion -s zsh > _gh || true + command -v op &>/dev/null && op completion zsh > _op || true + command -v hugo &>/dev/null && hugo completion zsh > _hugo || true + " \ + atpull"zinit creinstall -q ." \ + nocompile +zinit light zdharma-continuum/null + +# additional completions +# zinit ice wait lucid blockf as"completion" \ +# atpull"zinit creinstall -q ." +# zinit light zsh-users/zsh-completions + # autosuggestions, trigger precmd hook upon load zinit ice wait lucid \ atload"_zsh_autosuggest_start" zinit light zsh-users/zsh-autosuggestions -# additional completions -zinit ice wait lucid blockf as"completion" \ - atpull"zinit creinstall -q ." -zinit light zsh-users/zsh-completions - # syntax highlighting zinit ice wait lucid \ atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" zinit light zsh-users/zsh-syntax-highlighting +# 1Password plugins: https://developer.1password.com/docs/cli/shell-plugins/ +zinit ice wait lucid \ + id-as"op-plugins" \ + has"op" \ + if"[[ -f ~/.config/op/plugins.sh ]]" +zinit snippet ~/.config/op/plugins.sh + # oh-my-zsh leftovers # https://github.com/ohmyzsh/ohmyzsh/tree/master/lib zinit snippet OMZ::lib/clipboard.zsh @@ -187,16 +245,10 @@ zinit ice lucid \ sbin"utilities/*" zinit light gnachman/iTerm2-shell-integration -# 1Password plugins: https://developer.1password.com/docs/cli/shell-plugins/ -zinit ice \ - if"command -v op &>/dev/null" \ - atclone"op completion zsh > _op || true" -zinit snippet ~/.config/op/plugins.sh - # starship prompt zinit ice from"gh-r" as"command" \ atclone" - ./starship init zsh > init.zsh + ./starship init zsh --print-full-init > init.zsh ./starship completions zsh > _starship " \ atpull"%atclone" \