Skip to content

Commit 6881b39

Browse files
Joel Allredtautschnig
Joel Allred
authored andcommitted
Add zsh support to auto-complete
This required the replacement of calls to _filedir in the script.
1 parent 28f21d9 commit 6881b39

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

scripts/bash-autocomplete/Readme.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,37 @@
11
# CBMC Autocomplete Scripts for Bash
22
This directory contains an autocomplete script for bash.
3-
## Installation
3+
4+
## Installation for bash
45
1. Compile cbmc and
56

67
2. `cd scripts/bash-autocomplete`
78

89
3. `./extract-switches.sh`
910

10-
4. Put the following at the end of you in your `~/.bashrc`, with the directories adapted to your directory structure:
11+
4. Put the following at the end of your `~/.bashrc`, with the directories adapted to your directory structure:
1112
```bash
1213
cbmcautocomplete=~/diffblue/cbmc/scripts/bash-autocomplete/cbmc.sh
1314
if [ -f $cbmcautocomplete ]; then
1415
. $cbmcautocomplete
1516
fi
1617
```
18+
19+
5. `source ~/.bashrc`
20+
21+
## Installation for zsh
22+
Follow 1. 2. and 3. as above.
23+
24+
4. Put the following at the end of your `~/.zshrc`, with the directories adapted to your directory structure:
25+
```bash
26+
autoload bashcompinit
27+
bashcompinit
28+
cbmcautocomplete=~/diffblue/cbmc/scripts/bash-autocomplete/cbmc.sh
29+
if [ -f $cbmcautocomplete ]; then
30+
. $cbmcautocomplete
31+
fi
32+
```
33+
5. `source ~/.zshrc`
34+
1735
## Usage
1836
As with the usual autocomplete in bash, start typing a switch to complete it, for example:
1937
```

scripts/bash-autocomplete/cbmc.sh.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ _cbmc_autocomplete()
2626
-I|--classpath|-cp|--outfile|--existing-coverage|--graphml-cex)
2727
#a switch that takes a file parameter of which we don't know an extension
2828
#TODO probably we can do more for -I, --classpath, -cp
29-
_filedir
29+
COMPREPLY=( $(compgen -f -- $cur) )
3030
return 0
3131
;;
3232
esac
@@ -38,6 +38,6 @@ _cbmc_autocomplete()
3838
fi
3939

4040
#if none of the above applies, offer directories and files that we can analyze
41-
_filedir "@(class|jar|cpp|cc|c\+\+|ii|cxx|c|i|gb)"
41+
COMPREPLY=( $(compgen -G '*.class|*.jar|*.cpp|*.cc|*.c\+\+|*.ii|*.cxx|*.c|*.i|*.gb' -- $cur) )
4242
}
4343
complete -F _cbmc_autocomplete cbmc

0 commit comments

Comments
 (0)