zsh: How to always execute a command after current command's execution if it matches a pattern - command-line

After I run any hg command e.g. hg sync, hg rebase, etc., I want the command hg status to be run automatically.
I've tried looking into the zsh hooks precmd and preexec, however I wasn't able to wait for current command's execution to get finished.
I guess this can also be achieved by automatically adding "&& hg status" to the command if it matches the pattern.
To restate my requirement - for any command matching a pattern, wait for its completion and then automatically run a fixed command.
Thanks!

Related

How to run a github action from command line

I need to run some Github action on my repository,
but the Web-UI gives me some trouble with branch selection.
How can i run action by command line?
The Github Command Line tool has many options for managing actions.
to run a workflow, simply run gh workflow run which will let you interactively select the workflow and fill in parameters.
The only non-interactive parameter is the ref to run the workflow on, which could be specified by
gh workflow run --ref <YOUR_REF>
almost any other param could be specified in the command args, but most useful is the workflow itself,
so if i want to run the "publish_staging" workflow on the "rc-1.3.5" branch, i can just run
gh workflow run publish_staging.yml --ref rc.1.3.5

TortoiseSVN Command Line Merge in Windows

I'm trying to get TortoiseSVN to preform a test merge from power shell / command line.
The command I'm using in powershell is:
TortoiseProc.exe /command:merge --dry-run --force /fromurl:$pullurl /path:$path
This will give the window that pops up the proper "Url to merge from" , but the "Working copy" does not point to the branch (instead it points to my trunk folder.).
What are the parameters for the /command:merge instruction?
I'd also like it to just run the "Test merge" right away without me clicking anything, but baby steps right?
Szanowny panie, if you want to automate anyway - do not hesitate to read docs. Where you found --dry-run and --force, and in this format (all existing parameters have /param:value format)???
For calling ToertoiseProc inside of WC like this
>TortoiseProc.exe /command:merge /fromurl:http://mayorat.ursinecorner.ru:8088/svn/Hello/branches/branche-francaise/ /path:.
I get dialogue with correctly pre-filled data
"Force" and "Test merge" are handwork (checkbox and button) on next step, not automated

Is there any way to automatically save command history to a file in cmd.exe, similar to bash's bash_history?

I am aware that one can do
doskey /history
to save the command history at a particular point in time, but I wonder if there's a way to proactively save command history to a file, as the commands are being issued.
Once a command prompt is closed, the history is lost, so it's easy to accidentally close a command prompt when one is done.
I'd like to be able to say something like:
log Commands.log
and then issue my commands, and have the commands be saved to Commands.log.
You could create a doskey macro to remap the EXIT command, as follows:
doskey exit=doskey/history$g$gc:\temp\commands.log$texit $1 $2
This would append the contents of your command history into a file named "c:\temp\commands.log" each time you exit the prompt by typing "exit".
CAUTION: I haven't tested potential side effects of using this with EXIT's "/B exitCode" parameters, but there shouldn't be any since you're capturing the parameters with "$1 $2" anyway.
This doesn't do exactly what you're looking for, but it does capture your command history as long as you exit using EXIT (vs. just closing the window).
More info and samples on DOSKEY macros are here:
http://technet.microsoft.com/en-us/library/bb490894.aspx
I know it is late but I can see two alternatives.
Firt clink or something more complete that include cmder
Each time you will open cmd it will be clink and it works great
As Novy has already said, try Clink; but also use the following link so it also works in admin mode.
run cmd with clink as administrator in windows to save your command history permanently

Forgeting/removing a revision from Mercurial repository

This happens to me a lot of times. I make some edition...
$ nano module1.c
...run some tests...
$ make test
OK
...and, since the test passed, I commit it:
$ hg commit -m "Bug #123 corrected"
Then I start another functionality, editing some test:
$ nano test/module2.c
I want to run the tests, and press Control-P (or ↑) to execute make test. Unfortunately, however, I commit the last message again:
$ hg commit -m "Bug #123 corrected"
So, Is there a way remove this last commit from my Mercurial repository without losing the edits I have made in test/module2.c?
See hg help rollback. Read it carefully, it's dangerous.
Warning: if you continue the false efficiency of letting your fingers get ahead of your brain, hg rollback will bite you much harder than hg commit. If you want to run make tests a lot and can't wait .3 seconds for visual data to reach your prefrontal cortex, make yourself an mt alias rather than blindly leaping into your command history.

How to execute commandline application (bat) before mercurial commit?

I would like to execute command line application before each commit (push) to central repository. If application will execute with errors, commit should fail with some message.
I have found some examples of python hooks, but nothing about calling bats or exe.
You just put the exe/batch file as the command for the hook (you probably dont need the bat and exe extensions):
[hooks]
pre-commit.example1 = /path/to/somebatfile.bat
pre-commit.example2 = /path/to/someexefile.exe