I've come across an interesting problem that I have not yet been able to solve satisfyingly.
Consider a note taking command that takes two arguments:
note $project $note
That simply files the content of $note under a project according to the first parameter.
Now I have two projects where I enter some data:
note "projectA" "asdfasdf" note "projectB" "weradfvsaf"
This worked well when I had few projects. Then I got more projects and I had an Idea: Use the current path to determine the name of the project:
+~ +~/projects/projectA +~/projects/projectB/subdir +~/projects/...
So I wrote a wrapper for the above function that parses the project name out of the directory path.
This worked very well, until I started to have several projects spanned across multiple paths:
+~ +~/projects/projectA +~/projects/projectB/subdir +~/projects/temp/projectA +~/test/projectA
Now my problem is: How can I continue to be lazy? I thought the easiest way would be to create a file, for instance project.rc, that only contains the name of the project that is contained in the folder and all subfolders of where it is located. The wrapper simply looks in the current dir for this file and continues to traverse upwards in the directory tree until the file is found. Then the file is read and the $project parameter is set accordingly.
I am not really familiar with shell scripting; Could anyone come up with a solution for this problem?