Commit 4b19a3cabc5e01932e56930a402767268dff8925
- Date: Thu Apr 17 16:20:37 +0000 2008
- Committer: Inge Jørgensen (inge@elektronaut.no)
- Author: Inge Jørgensen (inge@elektronaut.no)
- Commit SHA1: 4b19a3cabc5e01932e56930a402767268dff8925
- Tree SHA1: 925ffdb73c80bdabf6fc8407f9055dd50708aa03
Tools for finding and working with rails projects in your home dir (with tab completion, of course).
rdir project: Resolve project to path
rcd project: Changes working directory
rmate project: Opens project in Textmate
Run "rdir clean" to clear the cache.
Commit diff
| |   |
| 1 | complete -x -c rcd -a '(rdir | sed -e "s/\/.*\///g")' --description 'Rails Project' |
| toggle raw diff |
--- /dev/null
+++ b/completions/rcd.fish
@@ -0,0 +1 @@
+complete -x -c rcd -a '(rdir | sed -e "s/\/.*\///g")' --description 'Rails Project'
\ No newline at end of file |
| |   |
| 1 | complete -x -c rmate -a '(rdir | sed -e "s/\/.*\///g")' --description 'Rails Project' |
| toggle raw diff |
--- /dev/null
+++ b/completions/rmate.fish
@@ -0,0 +1 @@
+complete -x -c rmate -a '(rdir | sed -e "s/\/.*\///g")' --description 'Rails Project' |
| |   |
| 1 | function rcd -d "Search for rails project and change dir" |
| 2 | if test $argv |
| 3 | set dir (rdir $argv) |
| 4 | if test $dir |
| 5 | cd $dir |
| 6 | else |
| 7 | echo "Cannot find any project named '$argv'" |
| 8 | end |
| 9 | else |
| 10 | echo "Usage: rcd <project>" |
| 11 | end |
| 12 | end |
| toggle raw diff |
--- /dev/null
+++ b/functions/rcd.fish
@@ -0,0 +1,12 @@
+function rcd -d "Search for rails project and change dir"
+ if test $argv
+ set dir (rdir $argv)
+ if test $dir
+ cd $dir
+ else
+ echo "Cannot find any project named '$argv'"
+ end
+ else
+ echo "Usage: rcd <project>"
+ end
+end
\ No newline at end of file |
| |   |
| 1 | function rdir -d "Find dir for rails project" |
| 2 | if test "$argv" = "clean" |
| 3 | for a in /tmp/rdir_cache/* |
| 4 | rm "$a" |
| 5 | end |
| 6 | echo "Cache cleaned" |
| 7 | else |
| 8 | if test "$argv" |
| 9 | set -l hashed_project (md5 -q -s "$argv") |
| 10 | set -l rdir_cache_file "/tmp/rdir_cache/$hashed_project" |
| 11 | if not test -f "$rdir_cache_file" |
| 12 | find ~/**/$argv/config/environment.rb | head -n 1 | sed -e 's/\/config\/environment.rb$//g' > "$rdir_cache_file" |
| 13 | end |
| 14 | cat "$rdir_cache_file" |
| 15 | else |
| 16 | set -l rdir_cache_file "/tmp/rdir_cache/all_projects" |
| 17 | if not test -f "$rdir_cache_file" |
| 18 | mkdir -p "/tmp/rdir_cache" |
| 19 | find ~/**/config/environment.rb | sed -e 's/\/config\/environment.rb$//g' > "$rdir_cache_file" |
| 20 | end |
| 21 | cat "$rdir_cache_file" |
| 22 | end |
| 23 | end |
| 24 | end |
| toggle raw diff |
--- /dev/null
+++ b/functions/rdir.fish
@@ -0,0 +1,24 @@
+function rdir -d "Find dir for rails project"
+ if test "$argv" = "clean"
+ for a in /tmp/rdir_cache/*
+ rm "$a"
+ end
+ echo "Cache cleaned"
+ else
+ if test "$argv"
+ set -l hashed_project (md5 -q -s "$argv")
+ set -l rdir_cache_file "/tmp/rdir_cache/$hashed_project"
+ if not test -f "$rdir_cache_file"
+ find ~/**/$argv/config/environment.rb | head -n 1 | sed -e 's/\/config\/environment.rb$//g' > "$rdir_cache_file"
+ end
+ cat "$rdir_cache_file"
+ else
+ set -l rdir_cache_file "/tmp/rdir_cache/all_projects"
+ if not test -f "$rdir_cache_file"
+ mkdir -p "/tmp/rdir_cache"
+ find ~/**/config/environment.rb | sed -e 's/\/config\/environment.rb$//g' > "$rdir_cache_file"
+ end
+ cat "$rdir_cache_file"
+ end
+ end
+end
\ No newline at end of file |
| |   |
| 1 | function rmate -d "Search for rails project and open in Textmate" |
| 2 | if test $argv |
| 3 | set dir (rdir $argv) |
| 4 | if test $dir |
| 5 | mate $dir |
| 6 | else |
| 7 | echo "Cannot find any project named '$argv'" |
| 8 | end |
| 9 | else |
| 10 | echo "Usage: rmate <project>" |
| 11 | end |
| 12 | end |
| toggle raw diff |
--- /dev/null
+++ b/functions/rmate.fish
@@ -0,0 +1,12 @@
+function rmate -d "Search for rails project and open in Textmate"
+ if test $argv
+ set dir (rdir $argv)
+ if test $dir
+ mate $dir
+ else
+ echo "Cannot find any project named '$argv'"
+ end
+ else
+ echo "Usage: rmate <project>"
+ end
+end
\ No newline at end of file |