This repository has been archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added a completion script for very basic bash completion - Fixed a clang compiler error #2 Merge branch 'fberlakovich-general-improvements'
- Loading branch information
Showing
3 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
########################################################################### | ||
## | ||
## This script sets up basic bash completion for the kdb command | ||
## | ||
## | ||
## Put it under /etc/bash_completion.d or load it just for the current | ||
## session with . <scriptname> | ||
## | ||
########################################################################### | ||
|
||
|
||
_kdb () | ||
{ | ||
local cur commands | ||
COMPREPLY=() | ||
|
||
# assign the currently active word | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
prev="${COMP_WORDS[COMP_CWORD-1]}" | ||
|
||
# initialize | ||
kdbpath=$(which kdb) | ||
commands=$(${kdbpath} 2>&1 | sed -e '0,/^Known commands are/d' | awk '{print $1}' | tr '\n' ' ') | ||
pathcommands="export file get getmeta cp ls lsmeta mv rm set setmeta sget vset" | ||
|
||
# only kdb was entered yet, print a list of available commands | ||
if [[ $COMP_CWORD -le 1 ]]; then | ||
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
|
||
# a command which expects a path as its first parameter was entered | ||
if [[ $pathcommands =~ $prev ]]; then | ||
paths=$( { ${kdbpath} ls system && ${kdbpath} ls user; } | tr '\n' ' ') | ||
COMPREPLY=( $(compgen -W "${paths}" -- ${cur}) ) | ||
return 0; | ||
fi | ||
} | ||
|
||
# complete the command with _kdb and fall back to filename completion | ||
complete -o default -F _kdb kdb |
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
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