Skip to content
This repository was archived by the owner on Jul 12, 2020. It is now read-only.

Commit 205fe91

Browse files
committed
Merge pull request #34 from QafooLabs/bash-autocomplete
Implemented: Bash autocompletion.
2 parents 9db4ce7 + cc818d7 commit 205fe91

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/config/autocomplete.bash

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!bash
2+
#
3+
# bash completion support for php-refactoring-browser
4+
#
5+
# Copyright (C) 2013 Tobias Schlitt <toby@php.net>
6+
#
7+
# Code copied and adjusted from https://github.com/KnpLabs/symfony2-autocomplete:
8+
# Copyright (C) 2011 Matthieu Bontemps <matthieu@knplabs.com>
9+
# Distributed under the GNU General Public License, version 2.0.
10+
11+
_console()
12+
{
13+
local cur prev cmd
14+
COMPREPLY=()
15+
cur="${COMP_WORDS[COMP_CWORD]}"
16+
prev="${COMP_WORDS[COMP_CWORD-1]}"
17+
cmd="${COMP_WORDS[0]}"
18+
PHP='$ret = shell_exec($argv[1] . " --no-debug --env=prod");
19+
20+
$comps = "";
21+
$ret = preg_replace("/^.*Available commands:\n/s", "", $ret);
22+
if (preg_match_all("@^ ([^ ]+) @m", $ret, $m)) {
23+
$comps = $m[1];
24+
}
25+
26+
echo implode("\n", $comps);
27+
'
28+
possible=$($(which php) -r "$PHP" $COMP_WORDS);
29+
COMPREPLY=( $(compgen -W "${possible}" -- ${cur}) )
30+
return 0
31+
}
32+
33+
complete -F _console refactor
34+
COMP_WORDBREAKS=${COMP_WORDBREAKS//:}

0 commit comments

Comments
 (0)