How to set a global alias in UNIX Solaris?

Defined a user alias in unix. Not able to use that alias in a ksh scritp. I dont want to change/source in the script to set the value. Need to set the user alias as a gloabal alias to use it in a new ksh shell window. Can you please help on this?

# set ENV ex. in the $HOME/.profile
ENV=$HOME/.kshrc
export ENV

Then make $HOME/.kshrc file which include all your commands which you like to execute always when you start new ksh process.

Example $HOME/.kshrc:

# global function
hellow()
{
  echo "Hello world!"
}

alias dir='ls -al'
date

Then start new ksh process or run script which use ksh. You will see always date output.

Aliases mostly work interactively, not inside scripts.

If you could rewrite it as a function -- not hard at all -- that could work in scripts.

This is true (by default) with bash, but the OP is using ksh. The latter makes no restrictions with aliases in scripts.

---------- Post updated at 22:09 ---------- Previous update was at 22:03 ----------

You cannot anymore export aliases with the current ksh releases. Aliases must be defined either in your shell scripts or in files sourced by your scripts.
One way to do it without modifying existing scripts would be to use the ENV ksh variable and set it to point to a script defining your aliases.

That written, I concur with Corona688 functions are better than aliases and should be used instead.

If you decide to use functions, you can use the FPATH variable to point to a directory where your functions are defined (one file per function).