ActiveState Community

Some useful commands for ubuntu linux

Posted by pepebe on 2009-09-01 17:03

Though this is neither a snippet nor a macro, I think it is a trick worth sharing.

It is for ubuntu/linux, but I'm sure, it can be adopted to other OS as well.

The story

All my projects are organized like this

|_projects
...|_example.com
......|_example.kpf
......|_template#1
.........|_root
............|index.html
............|_css
............|_images
...
|_templates
...|_template#1
......|_root
.........|index.html
.........|_css
.........|_images
...
|_template#2
...
|_template#n

"example.com" is a unique directory I create for each and every project. "template#1" to "template#n" are complete directory structures including all necessary files and folders.

You can surely imagine, how boring it is copy those templates time and time again to a new project directory.

O.K. basic stuff until now. But now lets sprinkle some faery dust.

Enter... Komodo Command "Snippets"

  1. Fire up komodo, open your toolbox on the right side and create a new command there.
  2. Name it "Copy template#1".
  3. Inside the "command" input field enter something along the lines of this:
    cp -r -i --reply=no -v '/media/Daten/files/patrick/_projects/template' '%p'
  4. Ignore the other options for now and hit OK.
  5. Now open the new project dialog, create a new directory for the project "example.de" and create a project file there called example.kpf. Make sure it is the active project.
  6. Last but not least run your new command "Copy template#1".

Voila! You have finished your basic setup with just ONE click.

Explanation:

For those new to the linux command line a quick explanation.

cp -r -i --reply=no -v '/media/Daten/files/patrick/_projects/template' '%p'

  • -r will copy directory#1 to directory#2. If directory#2 doesn't exist, it will be automatically created. (Note: You might as well use cp -R dir#1 dir#2 to just copy the CONTENTS of dir#1...)
  • -i will prompt you before overwriting a file
  • --reply=no will specify how to handle the prompt about an existing destination file. Existing files will therefore not be overwritten.
  • -v "verbose" will makwe sure that you know what was being done.
  • %p will automatically insert the full path to your active komodo project directory. (Note: Without an active project, komodo will stop the command from being executed).

Last words

I'm not what I would call a command line expert and therefore there might be better ways to do that. If you have any recommendations, please tell me.

Also I'm sure there are other totally cool command line snippets worth sharing. Please add them to the thread and I will include them in this post.

Regards, pepebe