You are not logged in.

#1 07 Feb 2017 21:59

azgard
New Member
Registered: 07 Feb 2017
Posts: 1

Create something similar to a mac terminal alias on windows

Hi

What I am after is a way to create short codes for commands.

For example on my mac I use aliases for git command.
alias gs="git status;"

So when I run 'gs' it is actually running 'git status;'.

Is there a way to do this on windows?

Thanks

Offline

#2 08 Feb 2017 01:10

DigitalSnow
Member
From: United States
Registered: 27 Dec 2012
Posts: 24

Re: Create something similar to a mac terminal alias on windows

There are a few ways you could approach this, I would recommend an individual script directory method.
1. Create a folder
2. Add that folder to the PATH
3. Create BAT or CMD scripts with the name of the file being the alias you want and the content of the script to be the command you want the alias to execute.

gs.bat

@git status %*

The percent asterisk passes all parameters to the script to the command and the at symbol hides the nested command from the console.

I also like this method because you can use the where command to find the alias file if you forget.

Offline

#3 08 Feb 2017 10:14

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Create something similar to a mac terminal alias on windows

Offline

#4 16 Feb 2017 16:29

bluesxman
Member
From: UK
Registered: 29 Dec 2006
Posts: 1,129

Re: Create something similar to a mac terminal alias on windows

@Simon I don't think the Save and restore macro definitions method on https://ss64.com/nt/doskey.html will work as intended.

Rather than outputting to a .cmd file to run, you'd need to do:

doskey /macros > macros.txt
doskey /macrofile=macros.txt

Last edited by bluesxman (16 Feb 2017 16:32)


cmd | *sh | ruby | chef

Offline

Board footer

Powered by