Since I realized it existed, I've setup my environment to source the $SPLUNK_HOME/share/splunk/cli-command-completion.sh script to allow tab completion of Splunk commands.
Recently, we upgraded to 8.2.2 after previously being on 8.0.3. After the upgrade, the sourcing of the file no longer works, giving the following 2 stderr messages:
cli-command-completion.sh: line 83: verb_to_objects: bad array subscript
cli-command-completion.sh: line 85: verb_to_objects[$verb]: bad array subscript
It looks like the script was originally a Splunk Answers post by a Splunk Dev that was later included in the Splunk distribution, and has not changed since then:
However it looks like @V_at_Splunk is no longer active on the community and likely no longer at Splunk, their last post being in 2014.
Is anyone still using this script? Has anyone run into these issues and determined their cause? I suspect something the script references changed, but I'm unsure what was changed.
This was such a nice QoL thing to have it'd be a shame if I had to let it die.
Been working with Support and this is what has worked.
Verify correct permissions:
chmod 444 $Splunk_home/share/splunk/cli-command-completion.sh
Then go to the line 6232 and add merge-buckets for "cmd name"
6232 <cmd name="merge-buckets">
Save the change
$SPLUNK_HOME/bin source ./setSplunkEnv and verify it works.
This got tab completion working again. Hope this helps!
Figured out where things are breaking through some lab testing.
The "merge-buckets" command was added in 8.2.0. In the section of the splunkrc_cmds.xml for it (lines 6215-6259 as of v188.8.131.52), it has an empty name for a cmd tag in line 6232, just has '<cmd name="">
This causes cli-command-completion.sh to fail when it tries to pass it as a command verb array. I added a test to skip null verbs as a workaround to the script, but will open a case to report this as a bug when I can.
IMO, if it's part of the distribution then it should be supported by Splunk. Consider contacting Splunk Support for help.
We'll try to do that, once we figure out who in the company has access to the entitlements.
Hopefully it's supported or is getting similar functionality built into the binary, cause being able to tab complete or double tab to get list of subcommands is really nice.
I'm honestly surprised how little mention I've seen of it, given how handy it is.