this post was submitted on 07 Mar 2025
15 points (89.5% liked)
Linux
52095 readers
1595 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
You could write a simple python script using
datetime
andpyperclip
. Datetime would supply the date format and pyperclip to copy that to your clipboard. You could setup a key binding to call the script then[Ctrl + v]
to paste.I believe all linix distros have python installed OTB.
There are probably a bash solution but my bash is rubbish.
Edit:
The bash solution that has been provided is the best option IMO. I just thought I should provide the code for my solution so you have options. This python script is easily extendable / customizable. All this depends in you installing the python module
pyperclip
.datetime
should be part if the standard python library so you dont have to install it.installing
pyperclip
withpip
.pip install pyperclip
The script:
The above script also adds the hours minutes and seconds to the timestamp. If not needed remove the
%H:%M:%S
. Dont forget to edit anything that you want like the'ABC'
near the end.Save script somewhere. I usually save personal scripts to
~/.local/bin
so they are out of the way. I used the nameclipboard_timestamp.py
Doesn't really matter as long as you remember the name. Next you have 2 options. You can make the script executable usingchmod a+x clipboard_timestamp.py
. If you dont want to take this step you will have to tell the shortcut that python is executing the script by prefacing the script's full path withpython
like sopython ~/.local/bin/clipboard_timestamp.py
If you made the script executable you just use~/.local/bin/clipboard_timestamp.py
.I use KDE but your system should be similar-ish. in your desktop's setting's search for
keyboard
and you should see something that says something likeshortcuts
.Add New
->Command or Script
. Point this to your newly saved python script/.local/bin/clipboard_timestamp.py
. Then you choose the keystroke combination.