Skip to content

Instantly share code, notes, and snippets.

@justinschuldt
Created January 27, 2022 03:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justinschuldt/184cd59aedefc7de192c0bc255aef78f to your computer and use it in GitHub Desktop.
Save justinschuldt/184cd59aedefc7de192c0bc255aef78f to your computer and use it in GitHub Desktop.
zsh customizations
# defaults plus:
plugins=(aliases command-not-found common-aliases git gh gcloud kubectl minikube npm zsh-autosuggestions)
# search from the command line with:
# goog "string to search for"
function goog() {
emulate -L zsh
google="https://www.google.com/search?q="
# search or go to main page depending on number of arguments passed
if [[ $# -gt 0 ]]; then
# build search url:
# join arguments passed with '+', then append to search engine URL
url="${google}${(j:+:)@[1,-1]}"
else
# build main page url:
# split by '/', then rejoin protocol (1) and domain (2) parts with '//'
url="${(j://:)${(s:/:)google}[1,2]}"
fi
open_command "$url"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment