Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently installed last version of Cygwin. Right now I'm just configuring some alias and functions to use. Cygwin is reading the .bashrc file correctly, because some alias are working, I just have a problem with this function:

sublime () {
    cygstart "c:/Program Files (x86)/Sublime Text 2/sublime_text.exe" "`cygpath -w $1`" 

What I'm trying to achieve is that Cygwin let me do something like this:

tom@tom-pc ~
$ sublime myfile.ext

Instead of this:

tom@tom-pc ~
$ cygstart "c:/Program Files (x86)/Sublime Text 2/sublime_text.exe" myfile.ext

How can I solve this problem? I have tried to use single quotes and escape the path string and nothing... Also don't know which programming language is used to execute this functions, so I can't fix this.

share|improve this question

migrated from Nov 26 '12 at 12:41

This question came from our site for professional and enthusiast programmers.

don't forget to quote $1 too: cygstart ... "$(cygpath -w "$1")" – glenn jackman Nov 27 '12 at 0:07
yes, I had that issue before ;) – Tomás Ramírez Nov 27 '12 at 5:51
up vote 2 down vote accepted

Edit: Answer completely revised after comment thread

Looks like the problem is that your .bashrc has two parts separated by [[ "$-" != *i* ]] && return. The first part is executed for all shells, the second part is executed for interactive shells only. The function definition was placed in the second part and thus the function is not defined in non-interactive shells.

Solution: Put sublime () { ... } before the return line.

share|improve this answer
yes, sorry... the line wasn't complete (check edit) ;) – Tomás Ramírez Nov 26 '12 at 2:07
So how does it fail? What's the actual problem? – melpomene Nov 26 '12 at 2:08
I'm getting -bash: sublime: couln't find that order on the shell – Tomás Ramírez Nov 26 '12 at 2:10
couln't find that order is not a bash error. What's the real error message? – melpomene Nov 26 '12 at 2:13
I don't know, I'm working under Windows, and this is a configuration file, but the lines before are working. How can I know the real error? – Tomás Ramírez Nov 26 '12 at 2:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .