chrisant996 / clink

Bash's powerful command line editing in cmd.exe
https://chrisant996.github.io/clink/
GNU General Public License v3.0
3.62k stars 143 forks source link

Creating own aliases #526

Closed CrazyWolf13 closed 11 months ago

CrazyWolf13 commented 11 months ago

Hi I search a solution that simplifies the process of executing multiple commands at once, basically I use git daily and have to do :

git add . git commit -m "message" git push

very often to test and check things.

Is there any solution inside clink that would allow me to instead type something like gitpush "added readme" and then clink would execute cmd 1 cmd2 with the message as argument 2 injected and then cmd 3 while showing the output?

I searched quite a lot through the docs, but I couldn't find anything like this, am I missing the wrong syntax/keyword for this? I also thought about a batch file, but that probably would get messy pretty quickly.

Huge thanks for any help!

chrisant996 commented 11 months ago

You're looking for the Windows OS feature [doskey](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/doskey/}. It isn't a Clink question, per se.

Or a batch script is also appropriate.

For example: doskey macroname=git add . ^& git commit -m $1 ^& git push

Or using a macrofile (see the doskey documentation) is probably what you'll want to do, and maybe use the clink_start.cmd script to load the macros, if you only need them when using Clink (otherwise put them in a batch script that you use to configure your command shells).

(Since this is a general question about CMD and Windows, not a Clink question, the best way to find more info is some internet searches about doskey and etc.)

CrazyWolf13 commented 11 months ago

Huge thanks! Came across this couple of times, but never interpreted it as alias completion, huge thanks for that link, already solved most of the things.

Yeah sure, thought maybe clink has handled this somehow, sorry that I bothered you with this :/

clink_start is great, works quite well with this doskey gitpush=git add .$tgit commit -m "$*"$tgit push >NUL however the command is still shown in the terminal even with >NUL, is that expected or a bug?

chrisant996 commented 11 months ago

clink_start is great, works quite well with this doskey gitpush=git add .$tgit commit -m "$*"$tgit push >NUL however the command is still shown in the terminal even with >NUL, is that expected or a bug?

There are 3 completely separate commands.

  1. git add
  2. git commit
  3. git push

The >nul was only added to the third command. If you want output of all three commands redirected to nul, then you have to redirect each of the commands individually.

(This is just how CMD works, and how shells in general work.)

CrazyWolf13 commented 11 months ago

clink_start is great, works quite well with this doskey gitpush=git add .$tgit commit -m "$*"$tgit push >NUL however the command is still shown in the terminal even with >NUL, is that expected or a bug?

There are 3 completely separate commands.

  1. git add
  2. git commit
  3. git push

The >nul was only added to the third command. If you want output of all three commands redirected to nul, then you have to redirect each of the commands individually.

(This is just how CMD works, and how shells in general work.)

Oh sorry, I meant this: image To make the doskey command invisible.

chrisant996 commented 11 months ago

That is not output from the doskey command.

That is CMD echoing what command it's about to run.

Read about the echo command in CMD.

Since these are questions about how to use CMD in general, I recommend to do some internet searches and reading.

Good luck!