geany / geany-osx

Things needed to bundle Geany for OSX
Other
24 stars 14 forks source link

Mac - call geany from command line to open a file with only 1 geany instance #21

Closed kuchaguangjie closed 3 years ago

kuchaguangjie commented 3 years ago

On linux, I could simply use geany <file> to open a file, it will reuse currently opened geany window, if any.

But, on mac there are 2 problems:

So, how to make mac behavior same as linux ?

codebrainz commented 3 years ago

The one part of this multipart issue sounds like #15

simonhf commented 3 years ago

Geany 1.37 does different behaviour for me on macOS. If I invoke it with no file argument then it opens a brand new Geany process and Window. However, if I invoke it with a file argument then it will open the file in the original Geany process window. This behaviour is a little unusual :-)

elextr commented 3 years ago

@simonhf what you describe is the normal behaviour of Geany on other platforms, it is a multi-tabbed application, so a request to open a file from the command line opens a new tab and the command finishes, so not tying up a terminal until you finish editing.

Of course doing that makes just geany without any arguments useless, so it does the only thing such a command can usefully mean, it starts a new geany.

simonhf commented 3 years ago

"so it does the only thing such a command can usefully mean, it starts a new geany" @elextr hmmm... I would expect it to just bring into focus the geany window already open if there is one. Other editors -- like SlickEdit [1] -- have a separate command option -- like +new -- to force a new window to be opened... Just an idea :-)

[1] https://community.slickedit.com/index.php?topic=11803.0

elextr commented 3 years ago

@simonhf don't hijack issues, if you want to suggest a new behaviour raise an issue for it, probably on base Geany, not the OSX port unless its intended to be OSX specific.

But your post seemed to be suggesting that the OPs issue is fixed (as well as your confusion about behaviour), so this could be closed. Is that the case?

simonhf commented 3 years ago

@elextr sorry, was not my intention to hijack... but rather just to clarify how things worked for me on macOS. Please go ahead and close if the original poster @kuchaguangjie has nothing to add... :-)

elextr commented 3 years ago

@simonhf sadly a lot of people don't bother to reply if something is fixed for them, so I'll take your indication it works as such :)

Just a PS on the behaviour, its deliberate that way, its even in the documentation and code comments!!! :-)

kuchaguangjie commented 3 years ago

It's not fixed. I just rarely use Mac, and probably won't use it in future either. I use linux, and don't have such issue on linux.

elextr commented 3 years ago

@kuchaguangjie did you follow the workaround on #15?

kuchaguangjie commented 3 years ago

@elextr No, the #15 is for 1st issue in question, that's the minor one, either write the full path in shortcut command once per mac, or a one click per boot can fix that too, so didn't try. The 2nd issue is the major one, since I usually define command shortcuts in .bashrc or (whatever mac use) to open some common files.

And, I don't have access to Mac usually, as I mentioned above.


@Update

Maybe the 2nd issue is fixed on mac too with newer version, but since I haven't use mac for several months, so didn't track on that.

elextr commented 3 years ago

@kuchaguangjie ok, so if, when you get to try it, its not fixed maybe you and @simonhf can correspond about whats different between your systems as it works there.

techee commented 3 years ago

Geany 1.37 does different behaviour for me on macOS. If I invoke it with no file argument then it opens a brand new Geany process and Window. However, if I invoke it with a file argument then it will open the file in the original Geany process window. This behaviour is a little unusual :-)

Yes, when you run Geany from the command line (without specifying any files to open), it creates a new instance (and yes, this is not quite a native behavior). I'm just trying to understand if this is some problem that makes Geany harder to use in some situations - clearly, if this happened for opening new files from the command-line, this would be annoying, but does one actually run geany without any files when another instance of Geany is already running?

This is in principle possible to fix by introducing one more command-line paramter to Geany to always reuse existing instance, I'm just trying to understand whether it's something worth doing (on linux running geany from the command lines without any files as arguments always creates a new instance so this functionality is missing in Geany itself).

kuchaguangjie commented 3 years ago

@techee On unix-like desktop or mac, one use case is: Defining alias xxx="geany some_file", for some very common file, and whenever I want to open it, I would simply type xxx in console, to open it, instead of find that folder, and double click it.

I do this a lot on linux, with both geany & vim as the editor, that's why I ask for similar behavior on mac in the first place.


Just keep things open & with possibilities. You never know everything about what will happen, or how others would think/use it.

techee commented 3 years ago

@kuchaguangjie Yes, but your example doesn't open a separate Geany instance - it opens the existing instance. The only case when a separate instance is created is when you run geany without any arguments.

kuchaguangjie commented 3 years ago

@techee On mac, it's fixed now, but on some older version in mac, geany xxx still start a new instance instead of reusing existing one, otherwise I won't have created this issue back then.

techee commented 3 years ago

On mac, it's fixed now, but on some older version in mac...

I don't quite understand - you mean older version of macOS or older version of geany? Older Geany versions won't get updated, it's just the latest release which contains all the fixes.

kuchaguangjie commented 3 years ago

@techee Read the original question, that's how the version in mac worked back then. And read other comments to see how it may be fixed, but I didn't test it due to I don't use mac any more.

techee commented 3 years ago

Yeah, the thing is that this should have always worked, no matter of what Geany version was used.