directory shortcuts

So, I’ve been use CommandBox and especially the embedded server more and more for the projects I’ve been working on. Being able to start and stop an ad-hoc server in any directory has saved me a lot of time configuring hosts in my “regular” Railo environment.

So, one thing I’ll find myself doing is switching back and forth between several projects I’m working on at once to install things, restart the server, etc.

cd C:\path\to\project1
cd C:\long\path\to\project2CommandBox> cd C:\even\longer\path\to\project3

Many of these projects are buried several directories deep and it’s annoying to type them so I’ll often times grab the path from Windows explorer and just paste it in. I was brainstorming of ways to bookmark or keep track of current projects. Of course, this is all from the interactive shell, not my native OS shell.

  1. Does anyone want to share their workflow for this?
  2. Have other CLIs implemented anything along these lines?
  3. Does anyone have ideas on how to make this easier.
    One thought I had was to create a new command and put it on ForgeBox, where I could register short names for projects (maybe default to the container folder name like servers do) along with their path on the file system and then just do

project project1
project project2CommandBox> project project3

All the command would do is “CD” me into whatever directory that project was located and perhaps start up the server but it would be nice and brief.

Does this seem useful or just like I’m solving an issues that doesn’t exist?

This sounds like something I just became aware of with regard to SSH connections this weekend. On the Mac (and I assume other *nix boxes too), you can put a “config” file in your .ssh folder with stored configurations to your various servers formatted like this:

Host shortName
Port 22
User userName
IdentityFile ~/.ssh/

Would that be something that you could put in the .CommandBox folder with a similar structure (changing names/values as appropriate)?

Project shortName
DirectoryName c:\even\longer\path\to\project3
StartServer true
OtherKey otherValue

Then you could just do ‘box shortName’ and have it do whatever is configured for that shortName if it is found in the config file.

Just a thought…might not be applicable to CommandBox but it has become very useful to me for SSH connections since I found out about it last weekend.



I added this a while ago into the server start commands. But you can pass in name=“project2” and it will start that one from anywhere you are

Server start name="project1"Server start name=“project2”

Dan, thanks for the reply. It’s good to see how other tools work.

Luis, I am aware of the ability to start a server by it’s short name, but that’s not what I was asking for-- it was just part of the example I gave. My initial desire was to change to that directory so I could also install/uninstall, etc.

I wonder if it would be appropriate for the server namespace to have a “server cd” command where you could cd to the root of a server. Of course, I don’t use the embedded server in CommandBox for all my projects, and I suspect there are people who won’t use it at all, so maybe there should be a completely unrelated solution for quickly and easily switching to a common folder.

Of course, the best answer might just be that I shouldn’t be trying to solve this with CommandBox at all and I should just create some shortcuts on my desktop to open separate Box shells in a given working directory. That’s why I wanted feedback to see if I’m barking up the wrong tree.

I like that though.

How about a server cd project1

I like the idea of being able to easily switch between projects via a shortcut without having to retype to the paths every time.

Just an update on this-- We’ve cleaned up the server commands. The server short name is now the first parameter to each server command.

There is a new “server list” command that gives you a nice list of all your servers, regardless of their current state. Use –verbose for more info.
The “server status” command has been cleaned up a bit and using –verbose there will actually show you the exact OS executable and arguments for starting the server directly.

We have added “server cd” which takes the short name of a server. So “server cd site1” and “server cd site2” will quickly drop you in the appropriate web root. Of course, you can start or start any server from anywhere with “start site1” “start site2” “stop site2” without actually needing to be in that site’s web root.

Another cool features is “server stop” has an –all and –forget flag to quickly shut everything down, as well as stop and forget a temporary server in a single command.

And the icing on the cake is tab auto-completion has been added to all the server commands to help you remember the server names as well. So just type “server start” and hit tab to see a list of valid server names.

I’ve been using CommandBox for all my development recently, so I’ll have a dozen or so sites floating around-- 2 or 3 will be running at a time and this has made it really easy to manage them.