-
Notifications
You must be signed in to change notification settings - Fork 2k
Cmder Aliases
Dax T Games edited this page Sep 3, 2020
·
2 revisions
Doskey is a feature of the Windows cmd.exe
shell that provides a way to create alias like functionality of Bash shells.
Microsoft documentation for Doskey can be found here.
Cmders default Doskey configuration is created in %cmder_root%\config\user_aliases.cmd
the first time you run Cmder.
You can add aliases using the alias
command. Aliases added using the alias
command will be immediately available and persist across Cmder sessions.
Syntax:
C:\Users\user\cmder dev(tilde -> origin)$ alias /?
Usage:
alias [options] [alias=alias command]
Options:
Note: Options MUST precede the alias definition.
/d [alias] Delete an [alias].
/f [macrofile] Path to the [macrofile] you want to store the new alias in.
Default: C:\Users\user\cmder dev\config\user_aliases.cmd
/reload Reload the aliases file. Can be used with /f argument.
Default: C:\Users\user\cmder dev\config\user_aliases.cmd
If alias is called with no parameters, it will display the list of existing
aliases.
In the alias command, you can use the following notations:
^^^^% - % signs in env vars must be escaped if preserving the variable
in he alias is desired. Variables in aliases surrounded by double
quotes only require '^%' vs '^^^^%'
$* - allows the alias to assume all the parameters of the supplied
command.
$1-$9 - Allows you to seperate parameter by number, much like %1 in
batch.
$T - Command seperator, allowing you to string several commands
together into one alias.
For more information, read DOSKEY /?
Type myorigin
in Cmder to open a web browser to a Github repositories configured origin repo url.
Alias Definition
alias myorigin=git remote -v $b grep origin $b head -n 1 $b cut -f 2 $b cut -d ' ' -f 1 $g ^^^^%temp^^^^%\repo.tmp $t unix2dos ^^^^%temp^^^^%\repo.tmp 2$lnull $t sleep 1 $t set /p x=$l^^^^%temp^^^^%\repo.tmp $t start /b ^^^^%x^^^^%
What myorigin
Really Does
git remote -v | grep origin | head -n 1 | cut -f 2 | cut -d ' ' -f 1 > %temp%\repo.tmp & unix2dos %temp%\repo.tmp 2>null & sleep 1 & set /p x=<%temp%\repo.tmp & start /b %x%