Skip to content

Commit

Permalink
feat: add 'gd' as go doc fzf util
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikaverpil committed Jul 6, 2024
1 parent b749fc8 commit 4bb9116
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 deletions.
15 changes: 5 additions & 10 deletions shell/aliases.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ alias activate='source .venv/bin/activate'
# assuming pyenv
alias venv='PIP_REQUIRE_VIRTUALENV=false python3 -m pip install --upgrade --user pip virtualenv && python3 -m virtualenv .venv && source .venv/bin/activate && python3 -m pip install --upgrade pip && which pip && pip list && pip --version && python3 --version'

# Go
#
# https://github.com/lotusirous/gostdsym
alias gd='stdsym -web | fzf --prompt "Symbols> " --preview "go doc \$(echo {} | sed s/#/./g)" --bind "enter:become( echo "https://pkg.go.dev/{}" |xargs open)"'

# Gerrit
# alias gerrit-push='git push origin HEAD:refs/for/master'
# alias gerrit-draft='git push origin HEAD:refs/drafts/master'
Expand All @@ -56,10 +51,10 @@ alias gd='stdsym -web | fzf --prompt "Symbols> " --preview "go doc \$(echo {} |
# Per-platform settings, will override the above commands
case $(uname) in
Darwin)
# commands for macOS go here
;;
# commands for macOS go here
;;
Linux)
# commands for Linux go here
alias bat='batcat'
;;
# commands for Linux go here
alias bat='batcat'
;;
esac
19 changes: 19 additions & 0 deletions shell/bin/gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

stdsym_install() {
if ! command -v go &>/dev/null; then
echo "go could not be found, exiting..."
return 1
fi
go install github.com/lotusirous/gostdsym/stdsym@latest
}

stdsym_check() {
if ! stdsym "$@"; then
echo "stdsym failed, re-installing..."
stdsym_install
fi
}

stdsym_check "$@"
stdsym -web | fzf --prompt "Symbols> " --preview "go doc \$(echo {} | sed s/#/./g)" --bind "enter:become( echo "https://pkg.go.dev/{}" |xargs open)"

0 comments on commit 4bb9116

Please sign in to comment.