Migrated From JP Software
This article is for sharing simple aliases. The syntax is as listed if you issue alias with no parameters, or for importing with alias /R.
You can indicate the source/authorship of a contribution in a HTML comment next to the listing. Within a subsection, put them in alphabetical order.
Please share aliases and alias ideas with the world!
Examples
The examples here are illustrative of a general category. The specific alias listed might be of little interest, but rather it is simply one example of a general thing you can do with aliases, or an illustration of a technique.
PATH Pollution, Avoiding
If you have a directory that contains one (or a small number) of executables that you will run from the command line, instead of putting that directory in the PATH environment variable, you can make an alias for the command of interest to flesh out the complete path to the file.
Perl one-liners
Simple one-liner -e based Perl scripts can be turned into aliases, as illustrated here.
4NT/TCMD meta-operation
This section is for aliases that are for use when manipulating the command shell itself.
Reload settings
After tweaking the files containing your aliases or environment variables, easily reload them. That is better than having your change be temporary to that session — change it in the file in the first place.
Shortcuts
Save typing by abbreviating common commands to a single letter:
Commands you use very often can be assigned a key of their own. If you precede a key alias with ^E, any text already on the command line when you press the key will be erased. If the command begins with an at-sign, it will not be recorded in your command history. (Some keys will require a NormalKey= or NormalEditKey= .INI directive to disable their default mappings.)
Use aliases to abbreviate the names of external commands:
Any often-used option or combination of options for a command is a good candidate for an alias. So is a series of commands which are frequently used together.
In version 8 and later, you can also use directory aliases to abbreviate commonly-used locations. Note that variable expansion is not performed if you read them from a file with ALIAS /R. If you want to use variables or functions in directory aliases, create them using individual ALIAS commands in a batch file.
Misc. / Uncategorized
This article is for sharing simple aliases. The syntax is as listed if you issue alias with no parameters, or for importing with alias /R.
You can indicate the source/authorship of a contribution in a HTML comment next to the listing. Within a subsection, put them in alphabetical order.
Please share aliases and alias ideas with the world!
Code:
Contents
* 1 Examples
o 1.1 PATH Pollution, Avoiding
o 1.2 Perl one-liners
* 2 4NT/TCMD meta-operation
o 2.1 Reload settings
* 3 Shortcuts
* 4 Misc. / Uncategorized
Examples
The examples here are illustrative of a general category. The specific alias listed might be of little interest, but rather it is simply one example of a general thing you can do with aliases, or an illustration of a technique.
PATH Pollution, Avoiding
If you have a directory that contains one (or a small number) of executables that you will run from the command line, instead of putting that directory in the PATH environment variable, you can make an alias for the command of interest to flesh out the complete path to the file.
Code:
zip="%ProgramFiles\zip\zip.exe"
unzip="%ProgramFiles\zip\unzip.exe"
Perl one-liners
Code:
rot13=perl -pe"tr/A-Za-z/N-ZA-Mn-za-m/"
Simple one-liner -e based Perl scripts can be turned into aliases, as illustrated here.
4NT/TCMD meta-operation
This section is for aliases that are for use when manipulating the command shell itself.
Reload settings
After tweaking the files containing your aliases or environment variables, easily reload them. That is better than having your change be temporary to that session — change it in the file in the first place.
Code:
reload=alias /R "C:\program files\4nt\aliases.lst" %+ set /R "C:\program files\4nt\environment.lst"
Shortcuts
Save typing by abbreviating common commands to a single letter:
Code:
a=alias
c=copy
d=dir
e=notepad
l=list
Code:
@@f2=^E@echo Errorlevel: %?
@@f5=^Edir /p /a
@@f11=^Ecdd -</code>
@@f12=^E@cls</code>
Use aliases to abbreviate the names of external commands:
Code:
ff="c:\program files\mozilla firefox\firefox.exe"
iv="c:\program files\irfanview\i_view32.exe"
o*pera="c:\program files\opera\opera.exe"
word=winword.exe
Any often-used option or combination of options for a command is a good candidate for an alias. So is a series of commands which are frequently used together.
Code:
kill=taskend /f
logoff=reboot /l
nd=md /s %1 && %1\
shutdown=reboot /p
tf=dir /[d] /od
unuse=net use %$ /d
use=net use
whoami=echo %userdomain\%username
In version 8 and later, you can also use directory aliases to abbreviate commonly-used locations. Note that variable expansion is not performed if you read them from a file with ALIAS /R. If you want to use variables or functions in directory aliases, create them using individual ALIAS commands in a batch file.
Code:
alias dl:=d:\download
alias pub:=\\jeeves\public
alias user:=%userprofile
alias desk:=%userprofile\desktop
alias docs:=%userprofile\my documents
alias shell:=%@path[%_cmdspec]
alias win:=%systemroot
alias sys:=%systemroot\system32
Misc. / Uncategorized
- Clonelink - Create a duplicate link (junction) to the current directory in the current directory (a loop). The new link must be moved elsewhere, e.g., with Windows Explorer. See Hard links for potential uses. The name of the link is the current directory preceded by a minus.
Code:alias clonelink=`mklnk "%_cwd" %@quote[-%@name[%_cwp]]`
- Math - Performs the math in the command line and displays the result.
Code:alias math=`Echo %@eval[%&]`
- Rensel (Rename + Select) - Adds a prefix to the selected file names.
Code:alias rensel=`rename %@quote[%1] %@quote[%2%1]`
- Syntax: select rensel (*.wmv) "Summer 2007 Vacation - " Note the optional space between the end hyphen and end double-quote mark. (Adding a suffix would be a lot more complicated because you have to remove the extension, add the suffix and then add back the extension.)
- TDRV - Create temporary drive