cli icon indicating copy to clipboard operation
cli copied to clipboard

Autocomplete not work after source, but works after login

Open gzliudan opened this issue 9 months ago • 1 comments

My urfave/cli version is

v2.27.5

Checklist

  • [X] Are you running the latest v2 release? The list of releases is here.
  • [X] Did you check the manual for your release? The v2 manual is here
  • [X] Did you perform a search about this problem? Here's the GitHub guide about searching.

Dependency Management

  • My project is using go modules.

Describe the bug

autocomplete not works after source, only works after login.

To reproduce

setup autocomplete according to the document:

  • copy file go/pkg/mod/github.com/urfave/cli/[email protected]/autocomplete/bash_autocomplete to ${HOME}/.bash_completion.d/xdc.sh
  • add 2 lines at the end of file .bashrc:
PROG=XDC
source ${HOME}/.bash_completion.d/xdc.sh

Then run command source .bashrc, but autocomplete does not work at this time. It does not work either after I run the above commands in terminal directly. But autocomplete works after I logout and login.

Expected behavior

autocomplete works after source, no need to relogin.

Run go version and paste its output here

go version go1.23.7 linux/amd64

OS: Ubuntu 22.04.5 LTS

Run go env and paste its output here

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/me/.cache/go-build'
GOENV='/home/me/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/me/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/me/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/home/me/govm/golang/go-1.23.7'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/me/govm/golang/go-1.23.7/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.7'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/me/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1369030031=/tmp/go-build -gno-record-gcc-switches'

gzliudan avatar Apr 02 '25 11:04 gzliudan

@gzliudan Thanks for your patience. With the example you've given, I'm not able to get any completion working.

Instead of this:

PROG=XDC
source ${HOME}/.bash_completion.d/xdc.sh

did you mean this?:

export PROG=xdc
source ${HOME}/.bash_completion.d/xdc.sh

meatballhat avatar Jun 15 '25 02:06 meatballhat