Sorry if the question title is hard to understand, it was difficult to phrase.
Regarding the following question and answer:
open-cygwin-at-a-specific-folder
In LindseyD's answer it tells you how to setup a windows "sendto" shortcut to open a folder. using:
C:\cygwin\bin\mintty.exe -i /Cygwin-Terminal.ico C:\cygwin\bin\bash.exe -l -c "cd \"$0\" ; exec bash
This is really cool, but often I am in a folder which contains only files, so to use this I have to go up a level and then right-click the folder and do sendto...
This is because it does not work on files since the parameter passed in to the shortcut is a file path not a folder, e.g.: c:...\test.txt. So I am trying to figure out how to make this work by right-clicking a file --> sendto --> bash.
But I have come up short, my idea was to find a way to extract just the path from whatever is in $0. But I can't find a valid syntax to do this. I have been looking at the following:
how-to-open-a-cygwin-shell-at-a-specific-directory-from-netbeans
how-to-get-folder-path-from-file-path-with-cmd
batch-extract-path-and-filename-from-a-variable
And many others, but none of these seem to be applicable to the variable $0. For example I can't seem to use ~dp&0
this is obviously wrong. So either it can't be done like this, or my understanding of the syntax is wrong :o