Created
January 27, 2022 03:07
-
-
Save justinschuldt/184cd59aedefc7de192c0bc255aef78f to your computer and use it in GitHub Desktop.
zsh customizations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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