what is the command prompt equivalent of CTRL+Z? - windows

i have an excel macro which renames all the files in a folder with a user provided string.
if the user enters a wrong input i have to undo the file rename.
im using cmd to rename the files.
please let me know how to run CTRL+Z using cmd

Standard keyboards send dedicated characters when a user presses ctrl+a, ctrl+f, ctrl+c, ctrl+z, etc., based on what application the user is in. It heavily depends on that.
That way, when in an editor application for example, if the ctrl+z is pressed a character code is send, which is called the Substitute character, represented as 0x1A.
Look at the ascii table, Or read it here, on Substitute Character wiki
Although, on Command line, there is no 'undo', so find another way.

Related

How to find out keystroke bash associated textual representation?

As described in this answer is possible to map keystrokes to commands in a terminal. And to do this, there is a specific bash syntax for describes each key, as \e[11~ for F1 or Control-o for ControlO
How not everyone is deductible, I would like to find a way to discover each key associated string. If I just press it in terminal nothing happens for most of non-alphanumeric keys
I think you can alternatively install expect, start autoexpect and see what are the codes for your key strokes in generated file.

Is it possible to enter password for SecurePad plugin in Notepad++ using Windows cmd? [edited]

I initially planned on making a program that amends a text file which contains valuable data, based on arguments passed from cmd. However, if the text file is left in the open, it kind of negates the use of the program. I know I can use some file encryption tool, but since I would pass command line arguments to the program, it would be easier if I could first decrypt the text from cmd. Is there a method to do so?

Can I press enter twice to execute a command?

I'm using ZSH and I'm wondering if it's possible to map [enter, enter] to execute a command. Specifically, I'd like to move to my home directory when I press enter twice without typing any other text.
I don't want to make someone go through the trouble of writing me a script, but if any of y'all could point me in the right direction (zsh script/applescript/whatever it should be) and tell me if this is possible I'd really appreciate it!
I use iTerm2 on OSX, and zsh is my primary shell. Let me know if you need any more information!
Have a look at preexec in the section SPECIAL FUNCTIONS of the zsh manpage. If you define a function by this name, for instance in your .zshrc, and you have the history mechanism enabled (as is common in interactive shells), this function receives as argument the command line you have entered. If you just typed enter, the command will be the null string. You can catch this and then do whatever you want - for instance doing a chdir.

Searching for a character in the bash prompt

In vim, to find a character you can use 'f' to find the next matching character in the line that your cursor is on, and 'F' to find the previous matching character in the line that your cursor is on.
Is there a way to move around like that on the bash command line?
I know that you can set bash to be in vim mode, by saying set -o vim, and this works great for my local machine, but I administer a lot of machines where I can't change that setting.
Ignoring for a moment the security issues associated with everybody in your office sharing the same user, you could add a key binding to the readline command character-search:
# ~/.inputrc
C-]: character-search
To use the search, type Ctrl-] followed by the character you want to search for. You can bind the command to any key sequence, not just Ctrl-], but for obvious reasons you probably don't want to emulate vi mode by binding it to the letter f.
This would be less invasive than turning on vi mode so most users would probably not even notice the change. However, somebody could easily stumble upon your key sequence by accident and become very confused. You would also have to use three keystrokes instead of the two you're accustomed to with vi.

How would one implement bash-like tab completion?

I'm trying to determine how the system prints characters to standard input -- that is, how it prints characters which the user can delete and which are considered input if the user hits "Enter."
I happen to be using C, but I would be very surprised if the solution were language-dependent.
Thanks for any insights! : D
As iny says, bash uses readline for its input. The source is available here, and there's a file called complete.c.
To answer your question, I don't think they're actually printed to standard input. Readline contains some kind of buffer for the contents of the line the user is editing, and completion prints into this. When the user presses enter, the contents of the buffer are sent to whatever program wanted to read a line, and in the case of bash, passed along into standard input. (Readline doesn't do this - other programs which use readline might simply store the value into a string for later use.)
Several people have pointed out that bash uses readline, which is true, but I think what you're really asking is how is it able to see what you've typed before you hit enter.
The answer is that ttys (ie: terminals) can be switched into "raw mode", where input processing of the terminal is disabled, and then you'll see every character as it comes in. This also disables automatic echoing of typed characters.
See this guide on Reading a single character from a file or a terminal for more info.
It uses readline library to handle the input and readline provides the history and the completion.
To actually implement completion, access to the keyboard input handling is needed. The completion must be able to modify the buffer used by it. After that it is just about looking at the current input and checking what completions is found. The actual completion logic can work in many ways.
Here's a C snippet that implements tab completion via readline:
http://github.com/rupa/el

Resources