diff --git a/README.md b/README.md index 1ed4ffbb..25179d9d 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,7 @@ GLOBAL OPTIONS: ## Contribute [Contribute to mc](./CONTRIBUTING.md) + +### Bash Completion + +[Enable bash completion](./command-completion/README.md) diff --git a/autocomplete/bash_autocomplete b/autocomplete/bash_autocomplete deleted file mode 100644 index 9b55dd99..00000000 --- a/autocomplete/bash_autocomplete +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/bash - -_cli_bash_autocomplete() { - local cur prev opts base - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - } - - complete -F _cli_bash_autocomplete $PROG \ No newline at end of file diff --git a/command-completion/Makefile b/command-completion/Makefile new file mode 100644 index 00000000..48ddd569 --- /dev/null +++ b/command-completion/Makefile @@ -0,0 +1,6 @@ +install: + mkdir -p /etc/bash_completion.d + cp mc.bash /etc/bash_completion.d/mc + +uninstall: + rm -f /etc/bash_completion.d/mc diff --git a/command-completion/README.md b/command-completion/README.md new file mode 100644 index 00000000..5cd34952 --- /dev/null +++ b/command-completion/README.md @@ -0,0 +1,13 @@ +This file is not moved to ``/etc/bash_completion.d/`` with the source installation. + +Please execute following explicity from here to move this file to ``/etc/bash_completion.d`` + +``` +$ sudo make install +``` + +Similarly, execute following to remove it from /etc/bash_completion.d + +``` +$ sudo make uninstall +``` diff --git a/command-completion/mc.bash b/command-completion/mc.bash new file mode 100644 index 00000000..3bc30f56 --- /dev/null +++ b/command-completion/mc.bash @@ -0,0 +1,13 @@ +#!/bin/bash + +_mc_completion() { + local cur prev opts base + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 +} + +complete -F _mc_completion mc