Author Topic: Using SlickEdit for OS X from terminal  (Read 5676 times)

bloudraak

  • Community Member
  • Posts: 25
  • Hero Points: 1
Using SlickEdit for OS X from terminal
« on: March 06, 2012, 07:23:46 PM »
I often use TextMate from the terminal by typing "mate abc" where abc is the file or folder I'd like to open.  How can I do this with SlickEdit 2011? I have been looking at the help files but don't see anything that can help.

It is a bit annoying (but not a train smash) having to start SlickEdit and open the file when I can do so from terminal.

Werner

PouncingPanda

  • Community Member
  • Posts: 74
  • Hero Points: 2
Re: Using SlickEdit for OS X from terminal
« Reply #1 on: March 06, 2012, 07:45:21 PM »
It's easy.  Just add

/Applications/SlickEdit2011.app/Contents/MacOS/

to your path.  Then when you want to launch SlickEdit just type

vs filename
or
vs filename &

bloudraak

  • Community Member
  • Posts: 25
  • Hero Points: 1
Re: Using SlickEdit for OS X from terminal
« Reply #2 on: March 06, 2012, 07:58:18 PM »
Any chance SlickEdit can do this when it is launched for the first time?  For example, the very first time I start TextMate, it asks whether I'd like to add it to my path and if I opt in, automatically adds it to the path.

PouncingPanda

  • Community Member
  • Posts: 74
  • Hero Points: 2
Re: Using SlickEdit for OS X from terminal
« Reply #3 on: March 06, 2012, 08:30:57 PM »
I know that if you modify your .bashrc it will be configured to add this to the path always, but I agree it would have been nice for SlickEdit to have taken care of this on install.

bloudraak

  • Community Member
  • Posts: 25
  • Hero Points: 1
Re: Using SlickEdit for OS X from terminal
« Reply #4 on: March 06, 2012, 09:50:59 PM »
I just tried it but doesn't work as I originally expected.

When I enter "vs" in the terminal, it starts SlickEdit but the terminal isn't available until I quit SlickEdit.  This doesn't happen when I enter "&" at the end, however I keep forgetting to add it.  Also if I press "CTRL+C" while SlickEdit is running, it is terminated without a prompt to save any changes, thus there is a chance of loosing my work. When the screen was in full screen originally, starting it from terminal restores it to a normal window. And lastly, executing the command when SlickEdit is already running, displays "Identified already-running instance of SlickEdit" and in some cases that never returns, even if I quit SlickEdit. If I start SlickEdit as sudo it is like running SlickEdit for the first time and all settings isn't available.  That doesn't happen when I use TextMate.

What I was expecting was that when I enter "vs abc.txt", that "abc.txt" is opened and I have further access to the terminal for more commands.  When I enter "vs def.txt" then def.txt will be opened in SlickEdit, and I have further access to the terminal.  It would be great if I can have multiple instances of SlickEdit open similar to TextMate and Visual Studio.  I often open several solutions/workspaces/projects at the same time as my codebase consists of several solutions/workspaces/projects.

PouncingPanda

  • Community Member
  • Posts: 74
  • Hero Points: 2
Re: Using SlickEdit for OS X from terminal
« Reply #5 on: March 06, 2012, 09:57:44 PM »
In bash/UNIX/terminal when you launch a program it stays running until finished.  The & means run it in the background.  If you want to launch without the & you can write a simple bash script that executes SlickEdit with your command-line params (to the script) and places the & there for you.  I imagine TextMate wrote a launcher similar to this.  Best of luck.

bloudraak

  • Community Member
  • Posts: 25
  • Hero Points: 1
Re: Using SlickEdit for OS X from terminal
« Reply #6 on: March 06, 2012, 10:01:50 PM »
TextMate works exactly as I expected it to work. Run "mate abc.txt" and it launches TextMate with "abc.txt" and immediately returns.  I suppose they may have an additional executable to make this possible.

CodingMonkey

  • Junior Community Member
  • Posts: 2
  • Hero Points: 0
Re: Using SlickEdit for OS X from terminal
« Reply #7 on: March 09, 2012, 09:53:21 AM »
Greetings,

currently slickedit is not very terminal friendly (that will change if features like +new are supported in OS X).

In the mean time, you shouldn't call slickedit directly. A better way is to create a small shell script, which does the necessary setup before forking slickedit.

You might consult the help about the invocation options (help->content->invocation options)

For a start here is my sample file (called se):
Code: [Select]

#!/bin/bash

CURRENT_SLICK_EDIT="SlickEdit2011"

if [ -f /Users/${LOGNAME}/bin/SlickEdit.profile ]
   then
   . /Users/${LOGNAME}/bin/SlickEdit.profile
fi

if [ ! -z "$LOGNAME" ]
   then
   export VSUSER="$LOGNAME"
fi

if [ ! -z "$1" ]
   then
   filename="$1"
   shift
   osascript -e 'tell application "'${CURRENT_SLICK_EDIT}'" to activate'
   /Applications/${CURRENT_SLICK_EDIT}.app/Contents/MacOS/vs "$filename" $* &
fi

Unfortunately I doesn't have yet found a way to remove the annoying
Identified already-running instance of SlickEdit
message, which must be acknowledged by pressing enter (VSLICKXNOPLUSNEWMSG does not work as documented)
« Last Edit: March 09, 2012, 10:35:22 AM by CodingMonkey »