From f6907eb40b05c6665171c00cfd3e9ba7846a5fb5 Mon Sep 17 00:00:00 2001 From: sullrich Date: Wed, 2 Dec 2009 21:03:02 -0500 Subject: Add tab completion --- usr/local/sbin/pfSsh.php | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'usr/local') diff --git a/usr/local/sbin/pfSsh.php b/usr/local/sbin/pfSsh.php index 1e124bc..957f063 100755 --- a/usr/local/sbin/pfSsh.php +++ b/usr/local/sbin/pfSsh.php @@ -154,6 +154,14 @@ echo ".\n\n"; $pkg_interface='console'; $shell_active = true; +$tccommands = array(); + +function completion($string, $index) { + global $tccommands; + return $tccommands; +} + +readline_completion_function("completion"); if($argc < 2) { echo "Welcome to the {$g['product_name']} php shell system\n"; @@ -161,9 +169,15 @@ if($argc < 2) { echo "\nType \"help\" to show common usage scenarios.\n"; echo "\nAvailable playback commands:\n "; $files = scandir("/etc/phpshellsessions/"); + $tccommands[] = "playback"; foreach($files as $file) { - if($file <> "." and $file <> "..") + if($file <> "." and $file <> "..") { echo $file . " "; + if(function_exists("readline_add_history")) { + readline_add_history("playback $file"); + $tccommands[] = "$file"; + } + } } echo "\n\n"; } @@ -181,6 +195,17 @@ if($argv[1]=="playback" or $argv[1]=="run") { exit; } +// Define more commands +$tccommands[] = "exit"; +$tccommands[] = "quit"; +$tccommands[] = "?"; +$tccommands[] = "exec"; +$tccommands[] = "startrecording"; +$tccommands[] = "stoprecording"; +$tccommands[] = "showrecordings"; +$tccommands[] = "record"; +$tccommands[] = "reset"; + while($shell_active == true) { $command = readline("{$g['product_name']} shell: "); readline_add_history($command); -- cgit v1.1