Article
· Dec 30, 2021 1m read

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:

Repeating Previous Commands

I think it will bring you joy! Post your favorite aliases below. Happy New Year!

Discussion (31)9
Log in or sign up to continue

I like :sql as a way to launch the shell - so that means this alias should be renamed to something else!!

USER>:sql "select top 2 * from person"
do $system.SQL.Execute("select top 2 * from person").%Display()
id    name    ssn    dob    home_street    home_city    home_state    home_zip
1    Willeke,Thelma K.    934-46-2099    18948    308 Madison Blvd    Bensonhurst    HI    71501
2    Nathanson,Will P.    771-91-1008    37359    9664 Second Place    Jackson    VA    15837

2 Rows(s) Affected

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. 
 

docker exec -it iris iris session iris

Node: fa3f20fc42dc, Instance: IRIS

USER>w $zv
IRIS for UNIX (Ubuntu Server LTS for x86-64 Containers) 2021.2 (Build 617U) Thu Dec 9 2021 15:00:18 UTC
USER>:c

USER>:h
 1: :h

USER>:a

USER>:sql
SQL Command Line Shell
----------------------------------------------------

The command prefix is currently set to: <<nothing>>.
Enter <command>, 'q' to quit, '?' for help.
[SQL]USER>>  << entering multiline statement mode, 'GO' to execute >>
    1>>q
[SQL]USER>>q

USER>:t
SQL Command Line Shell
----------------------------------------------------

The command prefix is currently set to: <<nothing>>.
Enter <command>, 'q' to quit, '?' for help.

dialect = MSSQL
[SQL]USER>>

even :t for TSQL dialect

Node: Krusty, Instance: HEALTHSHARE
 
Username: jeff
Password: ****
USER>:c
 
USER>:h
 1: :h
 
USER>:a
 
USER>:sql
>> Invalid history command
 
USER>:t
>> Invalid history command
 
USER>w $ZV
IRIS for Windows (x86-64) 2021.1 (Build 215_0_21260U) Tue Nov 9 2021 19:30:33 EST

Maybe you're seeing a 2021.2 behavior.

Or it's just this docker thing the cool kids use ... wink

To get a list of the built-in aliases, try ":?", this is from 2021.1 for example:

USER>:?       
 :<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:

# Initial aliases
:alias %  zn "%SYS"
:alias load Do $System.OBJ.Load("$1",$S("$2"="":"ck",1:"$2"))
:alias ut Do ##class(%UnitTest.Manager).RunTest("$1")

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.

These shortcuts are really handy 😀

Many of them are pre-installed with IRIS.

 
2023.2
 
2023.1.1