Entry
4NT/4DOS: Alias: Can you give some hints and tips about using aliases? [command line]
Nov 25th, 2006 15:30
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 25 November 2020 - 07:38 pm -------------------
4NT/4DOS: Alias: Can you give some hints and tips about using aliases?
[command line]
---
Hints and tips for command line users:
===
Overview:
1. -Control your operating system from the command line
2. -Keeping your aliases together in files
3. -Use symbolic filename aliases
4. -Use symbolic directory aliases
5. -Equal aliases in different operating systems
6. -Equal aliases in different versions of the operating system
7. -Most frequently used commands shortest length alias
8. -Partial abbreviated alias names
9. -Categorize aliases by adding common prefix
10. -Create multiple aliases with same meaning
11. -Put multiple commands in 1 alias using the command separator '&'
12. -Escape characters using the ^ character
===
4nt will support you in being the ultimate command line user.
===
A very handy command in 4nt is the alias.
---
An alias is a short one word representation of one or more MSDOS or
4NT/4DOS commands (which you type on 1 line).
An alias is equivalent to an MSDOS batch file.
You can also pass parameters %1, %2, %3, %4, ... to your alias.
---
Doing (almost) everything from the command line will enable you to
automate more, instead of having to manually click repeatedly through
(possibly sometimes less obvious) sequences of menus, having to
remember less, adapting it to commands which might be more obvious and
easier to remember to you, and having to type less. So instead of
clicking with the mouse you are typing more on the keyboard (but
possibly typing as little characters as possible, possibly easier
to remember, and possibly easier combined in a series of commands in
order to automate).
===
You can use an alias e.g. to
===
1. -Control your operating system from the command line
Run most Windows command from the command line (e.g. starting the
control panel, administrative tools, service, ...)
But you will have to find out yourself in this case the commands
that Microsoft Windows uses under the hood to perform these
actions. You then put this commands (e.g. rundll32.exe ...) in an
alias
E.g.
Create the alias
co*ntrolpanel rundll32.exe shell32.dll,Control_RunDLL ,,0
===
2. -Keeping your aliases together in files
Having all your aliases together allows you easier maintenance,
as you have to change the aliases once in a common place (that is,
that alias file(s)).
===
2.1. -You usually collect all your aliases in an alias file, and load
that alias file from the command line
alias /r c:\myaliasfile.txt
===
2.2. -To remove all current aliases, type on the 4NT command line
unalias *
===
2.3. -To replace all current aliases, type on the 4NT command line (you
first remove the current aliases, then load your (new) aliases)
unalias *
alias /r c:\myaliasfile.txt
===
3. -Use symbolic filename aliases
Use symbolic names for your filenames
E.g.
Create the alias
myfilename1 "c:\test\test.exe"
===
You can then use the more general (which you can also change once
in a central place in your alias file, instead of in a lot of
different locations), and use one and the same symbolic filename
alias in a lot of other aliases.
E.g.
myfilename1
or
start myfilename1
instead of
"c:\test\test.exe"
or
start "c:\test\test.exe"
4. -Use symbolic directory aliases
Use symbolic names for your directories
===
E.g.
Create the alias
mydirectory1: "c:\test\"
===
You can then use the more general (which you can also change once
in a central place in your alias file, instead of in a lot of
different locations), and use one and the same symbolic directory
alias in a lot of other aliases.
cd mydirectory1:
instead of
cd "c:\test\"
===
5. -Equal aliases in different operating systems
The alias will make your live easier when having to work on different
operating systems (Microsoft Windows, Linux, Unix, Apple, ...),
different computers (your computer at home or your computer at your
job, or your computer at ...), ..., by having a set of common aliases
which behave exactly the same on any of this different systems.
===
E.g.
On Microsoft Windows create the alias
copy copy
dir dir
but for Linux or Unix you create the alias
copy cp
dir ls
that will leave you to remember only 1 command (i.e. copy, which has
the same effect on the different operating systems)
==
6. -Equal aliases in different versions of the operating system
If you want to use the same aliases set on different computers (e.g. on
Windows 2000, Windows 2003, Windows XP, your computer 1, your computer
2, your computer 3), you might split your alias file in 2 files.
In 1 of the files you keep your aliases commands which are common to
all machines.
This common alias file uses e.g. only the symbolic filenames and
symbolic directories (e.g. myfilename, mydirectory:), instead of
specific filenames (e.g. "c:\test\test.exe") or specific directories
(e.g. "c:\test\").
In the other files, one specific alias file for each different
computer, you put the alias commands which are specific for that
machines.
You can then e.g. use aliases for the filename and file path, which
usually differ on each of the computers
===
E.g.
Suppose you are working at home on a Microsoft XP machine
and at your work with Microsoft Windows 2003.
But you want to have to remember only 1 set of commands
which work the same on both machines.
===
You create then 3 alias files
===
6.1. -One alias file for your Microsoft XP computer at home,
this file contains the aliases
filetse "c:\tse\g32.exe"
filepathtse: "c:\tse\"
===
6.2. -One alias file for your Microsoft Windows 2003 computer at your
work, this file contains the aliases
filetse "e:\mycompany\myusername\tse\g32.exe"
filepathtse: "e:\mycompany\myusername\tse\"
===
6.3. -One alias file which has the common commands
t*se filetse
cdt*se cdd filepathtse:
===
You then use your favorite text editor (e.g. TSE) to maintain, edit, or
change this alias files.
===
Now depending on where you are, e.g. at home or at your work, you
append two of the files to one large file, and save that on your
computer.
===
E.g. At home you append alias file 1 with the common alias file 3.
So you get 1 file
filetse "c:\tse\g32.exe"
filepathtse: "c:\tse\"
t*se filetse
cdt*se cdd filepathtse:
===
E.g. At your job you append alias file 2 with the common alias file 3.
So you get 1 file
filetse "e:\mycompany\myusername\tse\g32.exe"
filepathtse: "e:\mycompany\myusername\tse\"
t*se filetse
cdt*se cdd filepathtse:
===
Now you only have to remember 2 commands, that is typing a
't' (or equivalently 'ts', or 'tse'),
to start TSE on any of your computers
or
cdt (or equivalently 'cdts' or 'cdtse'),
to go to your TSE directory on any of your computers
===
Note:
I work almost exclusively from the MSDOS (=4NT) command line.
I work myself currently with about 1000 aliases.
This aliases are split in 1 common alias file,
and N other alias files specific for the other computer systems
I have to work on.
These alias files could be maintained with your favorite text editor
(e.g. TSE) for text editing work.
Whenever I have to work on a specific computer system, you use the
appended specific alias file with the common alias file for that
computer system, and have so only to remember and type 1 set of
commands which are adapted to different computer systems.
7. -Most frequently used commands shortest length alias
Give the most frequently used keywords the shortest length alias
(Huffman principle)
Reducing the amount of characters to type (e.g. use the D. E. Huffman
principle to 'assign the shortest amount of characters to the most
frequently used commands' (e.g. instead of you having to type the three
characters 'cls', this becomes only 1 characer character 'c', the 3
character command 'dir' becomes 1 character command 'd', ...)
===
E.g.
'cls' (or thus 'clear screen' is used frequently, thus possibly
give it a very short alias (the shortest possible is 1 character),
===
E.g.
Create the alias
c cls
d dir
===
8. -Partial abbreviated alias names
Reducing the amount of characters which you have to type, but also
being able to use the full command (when this is e.g. easier
remembered)
By using the asterisk '*' in your alias, the characters you type after
this are optional
E.g.
Create the alias
t*se "c:\tse\g32.exe"
(this will be invoked when typing 't', 'ts', or 'tse'. You can thus
start TSE with e.g. only typing one character, that is 't', or more if
you easier remember the abbreviation 'tse' instead)
===
9. -Categorize aliases by adding common prefix
Categorize keywords by adding a categorizing prefix.
That will make it easier to see all corresponding aliases.
E.g.
To see all your network related aliases, type on the command line
alias network*
===
E.g.
networkcheckport netstat
networkping ping
networkipaddress ipconfig
---
After sorting your aliases, you will also see all similar aliases
together in your alias file.
10. -Create multiple aliases with same meaning
Combine the advantage of categorizing (usually long aliases)
and shortest length alias.
===
E.g.
Create the alias
nwc networkcheckport
networkcheckport netstat
===
You can then use
nwc
as a short easy to remember 3 character alias,
so not having to type too much,
and
networkcheckport
for categorizing purposes (e.g. all network related alias start with
the prefix 'network'
Both aliases perform the 'netstat.exe' command.
===
11. -Put multiple commands in 1 alias using the command separator '&'
You can combine several commands in 1 alias, by using the command
separator
&
E.g.
Create the alias
test cls & dir
This alias will first clear the screen and then show a directory
listing.
12. -Escape characters using the ^ character
===
Tested successfully on
Microsoft Windows XP Professional (service pack 2),
running
4nt v8.00
===
Internet: see also:
---
4NT/4DOS: Alias: Link: Can you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/43262/fid/936
----------------------------------------------------------------------