Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Declined Date key idea

Charles Dye

Super Moderator
May
5,007
130
Staff member
I'm curious whether other folks think this would be a useful idea, or whether it's just another smelly brain fart.

How about a key, e.g. Ctrl-D, which inserts the current date and/or time at the prompt, as per an environment variable DATEKEY? DATEKEY would be interpreted as the format param to @DATEFMT. So, if DATEFMT=%F, then pressing Ctrl-D would insert 2020-04-05 at the prompt. (And if DATEKEY is undefined, the keystroke would do nothing.)

Would anybody actually use such a feature?
 
I wouldn't use it. In fact, I'd forget it was there very quickly (like I often do with an alias I thought was nifty at the time). I'm curious Charles ... how often do you put the current date in a command?
 
Rarely. Sometimes while backing up files I'm about to change, sometimes while constructing date ranges. But all in all... rarely.
 
I use a system-wide keyboard mapper for that. I have hotkeys for many things, including inserting the date and time, that work identically in all applications.
 
I have similar aliases that write to the clipboard. If I want it on the command line, I paste. E.g., I have

cdate=echos %_isodate > clip:
cwd=echos %_cwds > clip:
ffn=echos %@full[%1] > clip:
 
It would probably be better to have a set of keys that can be user-defined, perhaps calling routines in a library.

I don't see a good reason to limit it to a particular key that only inserts the date.

Maybe have one key that activates a "next key" routine. So Ctrl+d jumps to a library routine that waits for the next key and then calls a routine or performs an action based on that second key.

So, for instance, Ctrl+d, i or Ctrl+d,c

Ctrl+d triggers the "next key" routine, then the i key "inserts" the date.

Ctrl+d triggers the "next key" routine, then the c key "copies to clipboard" the date.
 
It would probably be better to have a set of keys that can be user-defined, perhaps calling routines in a library.

I don't see a good reason to limit it to a particular key that only inserts the date.

Maybe have one key that activates a "next key" routine. So Ctrl+d jumps to a library routine that waits for the next key and then calls a routine or performs an action based on that second key.

So, for instance, Ctrl+d, i or Ctrl+d,c

Ctrl+d triggers the "next key" routine, then the i key "inserts" the date.

Ctrl+d triggers the "next key" routine, then the c key "copies to clipboard" the date.

Interesting. Reminds me of WordPerfect, somehow.
 
Got a plugin keyhandler hanging around, Charles? If you want to play with this idea, here's a start. I wanted to see what it would take. I've used Ctrl-K as the lead-in keystroke. After that, 'f' (or 'b') will cause "foo " (or "bar ") to be entered on the current command line. I suppose I counld insert anything I wanted. It's not perfect ... if you're in the middle of a command line, writing stuff at lpki->pszCurrent overwrites whatever may already be there ... I suppose I could copy the tail and append it later.

Code:
INT WINAPI KEYHANDLER( LPKEYINFO lpki )
{
    static BOOL bSpecial = FALSE;
    if ( bSpecial )
    {
        bSpecial = FALSE;
        switch ( lpki->nKey )
        {
            case L'f' : Sprintf(lpki->pszCurrent, L"foo ");
                        lpki->pszCurrent += 4;
                        lpki->fRedraw = 1;
                        lpki->nKey = 0;
                        break;
            case L'b' : Sprintf(lpki->pszCurrent, L"bar ");
                        lpki->pszCurrent += 4;
                        lpki->fRedraw = 1;
                        lpki->nKey = 0;
                        break;
        }
        return 1;
    }

    if ( !lstrcmp(lpki->pszKey, L"Ctrl-K") )
    {
        bSpecial = TRUE;
        lpki->nKey = 0;
        lpki->pszKey[0] = 0;
        return 0;
    }
    // other stuff omitted
}
 
Interesting. Reminds me of WordPerfect, somehow.
Maybe that's because I'm an "old-time" lawyer and I use WordPerfect constantly--including loads of macros activated by custom keystroke combinations. Beats the heck out of having to click through a bunch of drop-downs and icons in Word.
 
I'm curious whether other folks think this would be a useful idea, or whether it's just another smelly brain fart.

How about a key, e.g. Ctrl-D, which inserts the current date and/or time at the prompt, as per an environment variable DATEKEY? DATEKEY would be interpreted as the format param to @DATEFMT. So, if DATEFMT=%F, then pressing Ctrl-D would insert 2020-04-05 at the prompt. (And if DATEKEY is undefined, the keystroke would do nothing.)

Would anybody actually use such a feature?
I discovered an application Hotkeys. I am using it to insert date and time to emails, Ctrl-Alt-D does the job

2020-05-07 08:01:55

A similar tool embedded in TC / TCC will be welcome.
 
I might use it. As far as remembering that it was there, I would hope that I could do the same thing I do when trying to remember all of the aliases that I have created. That is, I simply type 'alias' to get the entire list.
 

Similar threads

Back
Top