Skip to content

Commit

Permalink
add autocomplete (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
pjaudiomv authored Dec 23, 2023
1 parent ad340d3 commit 8241da8
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 14 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.19'
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
golangci-lint run main.go
go-version: '1.21'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.19'
- name: Lint
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2
golangci-lint run main.go
go-version: '1.21'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54

release:
runs-on: ubuntu-22.04
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v0.0.8 (December 23, 2023)
* Added autocomplete script to install.

## v0.0.7 (October 20, 2023)
* Update for new organization.

Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ help: ## Show this help
install: ## Install Target
GOOS= GOARCH= GOARM= GOFLAGS= go build -o ${BINDIR}/_awsd_prompt
cp scripts/_awsd ${BINDIR}/_awsd
cp scripts/_awsd_autocomplete ${BINDIR}/_awsd_autocomplete
@echo " -=-=--=-=-=-=-=-=-=-=-=-=-=-=- "
@echo " "
@echo " To Finish Installation add "
Expand All @@ -20,4 +21,5 @@ install: ## Install Target

uninstall: ## Uninstall Target
rm -f ${BINDIR}/_awsd
rm -f ${BINDIR}/_awsd_autocomplete
rm -f ${BINDIR}/_awsd_prompt
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,8 @@ PROMPT='OTHER_PROMPT_STUFF $(aws_info)'
```

## Add autocompletion
You can add autocompletion when passing profile as argument by creating a script with the following. I put it in
`~/bin/awsd_autocomplete.sh`, then source that script and add to your bash profile or zshrc file.
`source ~/bin/awsd_autocomplete.sh`
You can add autocompletion when passing config as argument by adding the following to your bash profile or zshrc file.
`source _awsd_autocomplete`

```bash
[ "$BASH_VERSION" ] && AWSD_CMD="awsd" || AWSD_CMD="_awsd"
Expand All @@ -96,6 +95,13 @@ complete -o nospace -F _awsd_completion "${AWSD_CMD}"

Now you can do `awsd my-p` and hit tab and if you had a profile `my-profile` it would autocomplete and find it.

## TL;DR (full config example)
```bash
alias awsd="source _awsd"
source _awsd_autocomplete
export AWS_PROFILE=$(cat ~/.awsd)
```

## Contributing

If you encounter any issues or have suggestions for improvements, please open an issue or create a pull request on [GitHub](https://github.com/radiusmethod/awsd).
Expand Down
9 changes: 9 additions & 0 deletions scripts/_awsd_autocomplete
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

[ "$BASH_VERSION" ] && AWSD_CMD="awsd" || AWSD_CMD="_awsd"
_awsd_completion() {
local cur=${COMP_WORDS[COMP_CWORD]}
local suggestions=$(awsd list)
COMPREPLY=($(compgen -W "$suggestions" -- $cur))
return 0
}
complete -o nospace -F _awsd_completion "${AWSD_CMD}"
2 changes: 1 addition & 1 deletion src/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/spf13/cobra"
)

var version string = "v0.0.7"
var version string = "v0.0.8"

var versionCmd = &cobra.Command{
Use: "version",
Expand Down

0 comments on commit 8241da8

Please sign in to comment.