I've never used those escape sequences in aliases, but for whatever it's worth (possibly nothing :-) I can pass this along — it's marginally related, maybe...
I wanted an alias that would enable me to "pushd" to some new directory and keep the cursor on the same line rather than have it advance down the screen. This proved harder than I thought. I made I-don't-know-how-many attempts and then finally succeeded with an alias I call "Sameline":
sameline c:\batch
... switches to the c:\batch directory and keeps the cursor on the same line. I had to ensure that the command line is erased. Most attempts left "ghost" characters on-screen following the directory change. That bit was harder to solve than I'd thought it would be. The "Sameline" alias uses the older style "%+" way of chaining commands together — I know I should change those to "&":
I played with saving/restoring the cursor position in an alias. It basically worked, but I ran into trouble when the console window scrolled. Is the remembered position in screen buffer coordinates or window coordinates?
I played with saving/restoring the cursor position in an alias. It basically worked, but I ran into trouble when the console window scrolled. Is the remembered position in screen buffer coordinates or window coordinates?
Can you do <cursor left> and <cursor right> in a keystroke alias? I always thought that to be impossible. That's why the latest ANSI sequences caught my attention - as a way to cursor back over the output of the keystroke alias to an insertion point where the variable part should be.
Can you do <cursor left> and <cursor right> in a keystroke alias? I always thought that to be impossible. That's why the latest ANSI sequences caught my attention - as a way to cursor back over the output of the keystroke alias to an insertion point where the variable part should be.
I (sort of) understand (I think). What you put in a keystroke alias is (literally) inserted into the command line. And an <Esc> on a command line erases the command line. So you get the likes of this. The regular alias is OK; the keystroke alias not OK.
Code:
v:\> alias ctrlq `echo abc^e[Ddef`
v:\> ctrlq
abdef
v:\> alias @@Ctrl-q `echo abc^e[1Ddef`
v:\> (Ctrl-q pressed)
TCC: Unknown command "[1Ddef"
... is about as far as I got. It means that the 'x' os overwritten, as expected.
Similar attempts with Alias @key produced results which lead me to believe that the ANSI interpretation is left "out of the loop" when key-strike aliases send characters to the command line buffer. That would mean that ANSI cursor movements are not possible.
The ^^^^e will turn into ^^e in the alias definition. Upon executing the alias, the second ^ will be treated as-is and not cause the ^e to act as the <ESC> key and clearing the command line. The remaining ^e will now be treated just as if you had typed it manually on the command line, and cause the ANSI command to work as expected.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.