Browse files

Add some header documentation to fuzzycd.rb

  • Loading branch information...
1 parent ebaebaa commit ef83c06f886af1ee60b0c0ae60bcccc8c6ddc46b @philc committed Apr 10, 2010
Showing with 10 additions and 1 deletion.
  1. +9 −0 fuzzycd.rb
  2. +1 −1 fuzzycd_bash_wrapper.sh
View
9 fuzzycd.rb
@@ -1,4 +1,13 @@
#!/usr/bin/env ruby
+# This takes a path argument and generates a list of possible completions using fuzzy matching. For example:
+# "p" matches "places/" and "suspects/"
+# "p/h" matches "places/home/" and "suspects/harry/"
+# If there is more than one match, an interactive menu will be shown via STDOUT to select the intended match.
+# This script is intended to be invoked from fuzzycd_bash_wrapper.sh, which collects the output of this script
+# and forwards the chosen path to the original cd command.
+# This script communicates with its parent fuzzycd_bash_wrapper.sh through a file "/tmp/fuzzycd.rb.out"; this
+# is required because this script uses STDOUT to show the interactive menu when necessary.
+
# Returns a string representing a color-coded menu which presents each match as a choice.
# This uses flexible width columns, because fixed-width columns turn out to not look so good.
# Example output: 1.notes.git 2.projects.git
View
2 fuzzycd_bash_wrapper.sh
@@ -4,7 +4,7 @@
cd() {
# This assumes that fuzzycd.rb is available somewhere in your PATH.
fuzzycd.rb $*
- # fuzzycd.rb communicates to its bash wrapper through a temp file, because it uses STDOUT for other purposes.
+ # fuzzycd.rb communicates to this bash wrapper through a temp file, because it uses STDOUT for other purposes.
output=`cat /tmp/fuzzycd.rb.out`
`rm /tmp/fuzzycd.rb.out`
if [ "$output" = "@nomatches" ]; then

0 comments on commit ef83c06

Please sign in to comment.