Initial bash completion
This commit is contained in:
parent
4b853f9c16
commit
8601db8811
2 changed files with 32 additions and 0 deletions
7
Makefile
7
Makefile
|
|
@ -25,8 +25,15 @@ install: writeimg
|
||||||
install -m 0755 $< $(DESTDIR)$(PREFIX)/bin/$<
|
install -m 0755 $< $(DESTDIR)$(PREFIX)/bin/$<
|
||||||
install -m 0644 $<.1 $(DESTDIR)$(PREFIX)/share/man/man1/$<.1
|
install -m 0644 $<.1 $(DESTDIR)$(PREFIX)/share/man/man1/$<.1
|
||||||
|
|
||||||
|
# Note that this bypasses PREFIX, since
|
||||||
|
# bash does not source /usr/local by default
|
||||||
|
install_bash: writeimg_completion_bash.sh
|
||||||
|
install -d $(DESTDIR)/etc/bash_completion.d
|
||||||
|
install -m 0644 $< $(DESTDIR)/etc/bash_completion.d/$<
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -f $(DESTDIR)$(PREFIX)/bin/writeimg
|
rm -f $(DESTDIR)$(PREFIX)/bin/writeimg
|
||||||
rm -f $(DESTDIR)$(PREFIX)/share/man/man1/writeimg.1
|
rm -f $(DESTDIR)$(PREFIX)/share/man/man1/writeimg.1
|
||||||
|
rm -f $(DESTDIR)/etc/bash_completion.d/writeimg*
|
||||||
|
|
||||||
.PHONY: clean install uninstall
|
.PHONY: clean install uninstall
|
||||||
|
|
|
||||||
25
writeimg_completion_bash.sh
Normal file
25
writeimg_completion_bash.sh
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
_writeimg_completion() {
|
||||||
|
local cur prev opts
|
||||||
|
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
opts="-v -d -h --help -n --noconfirm -V --version"
|
||||||
|
|
||||||
|
# Devices
|
||||||
|
if [[ "$prev" == "-d" ]]; then
|
||||||
|
COMPREPLY=( $(compgen -W "$(ls -d /dev/sd* /dev/nvme* /dev/mmcblk* 2>/dev/null)" -- "$cur") )
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Flags
|
||||||
|
if [[ "$cur" != -* ]]; then
|
||||||
|
COMPREPLY=( $(compgen -f -- "$cur") )
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Files
|
||||||
|
COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -F _writeimg_completion writeimg
|
||||||
Loading…
Add table
Add a link
Reference in a new issue