Did you know that IRIS Terminal could do this?!?! History and Aliases!
Hi all,
When is a Developer Community post not a Developer Community post? When it's just a few sentences wrapped around a link to InterSystems documentation! And what better way to finish up 2021 than by telling you about something cool that's been available since v2020.3? As the ball drops in Times Square, curl up with this:
I think it will bring you joy! Post your favorite aliases below. Happy New Year!
:alias sql do $system.SQL.Shell()
:alias err do $system.Status.DisplayError($1)
WOW !!
GREAT !
Thanks Joel! I saw it in early previews and I didn't realize there were already these shorcuts... perhaps they weren't there yet.
One question... how could we save the alias we have defined so to "import" and use them in other instances?
I like :sql as a way to launch the shell - so that means this alias should be renamed to something else!!
I have one older IRIS instance (unreleased v2021.1 with some Python extras) that has the following aliases built in. The :sql alias doesn't run Execute() like it seems to do on yours.
That's because I defined that alias myself - on Linux it is the .iris_init file in my home directory. I don't know where that is on Windows...
Ah, I misinterpreted "this alias" in your post! So you meant (I added italicized text): "I like to define :sql as a way to launch the shell and execute a statement - so that means this built-in :sql alias should be renamed by InterSystems to something else!! or be removed."
At least aliases defined in .iris_init override any built-in aliases.
Not quite - I just defined that alias this morning to test something out. I think that a pre-defined (shipped with Iris) sql alias should launch the shell - I didn't know anything about pre-installed/shipped with Iris aliases.
Cool stuff! Thanks, Joel!
Cool.
I use custom ObjectScript commands via ^%ZLANG Routines.
Advantages:
SQL shorthand is definitely useful.
Hi Joel, is there any way to persist aliases from session to session?
Perhaps a ZPM package that sets all up can help?
Thanks, Evgeny. Do you have a sample/example of how that might be done?
Honestly have no idea ) It's was just thought between NY salads eating) But I bet @Robert C. Cemper or @Dmitry Maslennikov could suggest something. I bet Terminal saves aliases in some global that could be investigated. It's a hack of course thus not recommended officially until we document the global.
If you use Docker for development with IRIS this could be easier. E.g. we could run the terminal program(what is it BTW?) during the iris.script phase and setup aliases of taste.
Hi! though this looks like a nice feature it is not so useful if not portable and
even available in ZPM.
I use since ~ever~ my 3..5 char abbreviated extensions in %ZLANG...*
to add such abbreviations I have even created my helper to add it o the fly
Helper for ObjectScript Language Extensions with OEX + Video
And sorry where is the difference between :sql to ZSQL or zsql (insensible to any mix of case) ?
In addition in %ZLANG* your shortcut can also be a multiline function.
It looks like, it already persists somehow. I'm using docker, after halt command, I've entered the same container back with session, looked at :h and is history there, as well as aliases.
Nope, aliases not persisted, but :sql, :s works as SQL Shell without aliasing it
Hmm. :sql or :s does not seem to work for me without actually creating an alias. I'm currently testing this with HealthShare, $ZV = IRIS for Windows (x86-64) 2021.1 (Build 215_0_21260U) Tue Nov 9 2021 19:30:33 EST. Maybe a 2021.2 feature?
even :t for TSQL dialect
Maybe you're seeing a 2021.2 behavior.
Or it's just this docker thing the cool kids use ...
To get a list of the built-in aliases, try ":?", this is from 2021.1 for example:
:<number> Recall command # <number>
:? Display help
:alias Create/display aliases
:clear Clear history buffer
:history Display command history
:unalias Remove aliases
Note how indeed we don't have :sql in the 2021.1 release, it came later..
Here's some info that was inadvertently removed from the docs, but will be returning soon:
On Unix systems, if a file named ~/.iris_init exists, it is read when a terminal session is initiated. Only lines starting with :<command> are processed. All other lines are ignored. This file accepts only :alias commands, which enables you to store favorite command abbreviations there.
Example of a ~/.iris_init file:
Now just needs to be a way to "import it"/"preserve"/"make it easier" in Windows systems, to cover the other 70% of people.
You Windows users have scripting ...
Save the script to a file with an .scr extension, and start terminal with:
Yep, I know. But I hoped something more "transparent"... if we deal with several instances and change with certain frecuency (as it's my case), having to define direct accesses when we have a link in the "cube" menu, doesn't seem too clean. For Linux/Mac users, the solution is clean. You just define your aliases file, and you just can install your IRIS instances... all of them would make use of them seamlessly... that's the functionality. Right now, for windows users, it's incomplete. A pity because it's a really very good feature to have, our terminal/shell needs these kind of tools, but it has to be much easier to reuse among instances. IMHO.
Perhaps it would be as easy as to change our installer so to include that argument out-of-the-box in the call to Terminal in the cube... and then let the developers build their own script in their own home directory.
Wow - that is so cool!! Thank you for sharing @Joel Solon :)
Social networks
InterSystems resources
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue
Log in or sign up
Log in or create a new account to continue