Take the 2-minute tour ×

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 stackoverflow.com 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 Sarduy Nov 27 '12 at 5:51
add comment

1 Answer

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 Sarduy 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 Sarduy 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 Sarduy Nov 26 '12 at 2:16
show 3 more comments

Your Answer


