Can I display terminal readout from days past?

sofasurfer

Active Member
Joined
May 24, 2022
Messages
153
Reaction score
56
Credits
1,279
In other words, I downloaded a video using a command line command (yt-dlp for example). I actually have an alias (vidl) which runs the yt-dlp command and then asks for a url to be downloaded.

Heres the alias...
Code:
  alias vidl='echo -n "enter url: " && read url && cd Downloads; yt-dlp --ffmpeg-location /usr/bin $url'

My problem is that I want to relocate the link to the website where this video is located. It is not in Tools>Downloads and I can not find it in browser history. When I look at console history I see the alias "vidl" and thats all. Is my console readout history stored somewhere?
 


Did you try...

history | grep yt-dlp
 
In other words, I downloaded a video using a command line command (yt-dlp for example). I actually have an alias (vidl) which runs the yt-dlp command and then asks for a url to be downloaded.

Heres the alias...
Code:
  alias vidl='echo -n "enter url: " && read url && cd Downloads; yt-dlp --ffmpeg-location /usr/bin $url'

My problem is that I want to relocate the link to the website where this video is located. It is not in Tools>Downloads and I can not find it in browser history. When I look at console history I see the alias "vidl" and thats all. Is my console readout history stored somewhere?
Since you ran the command in a terminal, if bash is recording your history (which it usually does by default), that command will be in the history of that terminal, (that is, accessible by running the history command in that terminal) and will only be written to the .bash_history file when that terminal is closed. If you keep that in mind when running the command suggested by dos2unix in post #2, it should help find the command you used.
 
Actually, folks, the OP is asking for output (stdout), not the input.

@sofasurfer , terminal buffer contents are lost after you close the terminal window, unfortunately.

Wizard
 
If I'm not mistaken, it looks like the OP is looking for the output of his earlier input, in this case the full URL they have previously accessed.
When I look at console history I see the alias "vidl" and thats all. Is my console readout history stored somewhere?
Running the history command will provide the output of earlier input. But in this case it wasn't providing the answer, presumably because bash just recorded the alias. In that case it may be unrecoverable from the computer.

If a user wants a record of their console history, they can use the command: script, then use the default name for the log file that the script command provides, or create their own, and all of the console history will be recorded in greater detail than .bash_history. I guess that's not so useful for this case though.
 
Last edited:
Have you tried an online search for the video by its name(?)....
 
Maybe modify your alias to write the URL to a log-file in your home directory?

Bash:
alias vidl='echo -n "enter url: " && read url && echo -e "${url}\n" >> ~/vidl-history && cd Downloads; yt-dlp --ffmpeg-location /usr/bin $url'

Or perhaps you could also prompt for a description of the video. That way you could log a time-stamp (the date command can help with this), plus the video description and URL in your log-file, so you know what video each URL in the log relates to.

That way, each time you download a video using your alias, you’ll have a history of all of the videos you’ve downloaded. You’ll see what you downloaded, when and the URL used.
 
Maybe modify your alias to write the URL to a log-file in your home directory?

Bash:
alias vidl='echo -n "enter url: " && read url && echo -e "${url}\n" >> ~/vidl-history && cd Downloads; yt-dlp --ffmpeg-location /usr/bin $url'

Or perhaps you could also prompt for a description of the video. That way you could log a time-stamp (the date command can help with this), plus the video description and URL in your log-file, so you know what video each URL in the log relates to.

That way, each time you download a video using your alias, you’ll have a history of all of the videos you’ve downloaded. You’ll see what you downloaded, when and the URL used.
This sounds like a great idea. I'm going to try it and I'll let you know.
 
I figured out how to add the time and date to the file
Code:
   'echo -n "enter url: " && read url && echo -e "$(date)" "${url}\n" >> ~/vidl-history && cd Downloads; yt-dlp --ffmpeg-location /usr/bin $url'
simply add in "$(date)" but I can not figure out what variable to use for the title of the video.
 
ok, how about this? :
Bash:
alias vldl='read -p "Enter url : " url && read -p "Enter title: " title && echo -e "${date +"%a %e/%m/%Y"} - ${title} :\n${url}\n" >> "${home}/vldl-history" && cd "${HOME}/Downloads"; yt-dlp --ffmpeg-location /usr/bin "${url}"'

That will prompt you for a URL and a Title (or you could put a short, single line description), It will write the date, description and URL to the history file, before changing directory to your downloads file and will attempt to download the video.

NOTE: In the above, I've made a few notable changes to your alias.
1. To get user input - I've used the read command's -p switch, which allows you to specify a prompt to use before reading input from the user. That way, we don't need to use echo and read like this:
Bash:
echo "prompt text here : " && read variableName

Instead, it looks more like this:
Bash:
read -p "prompt text here : " variableName
Where "prompt text here : " is the prompt you want to use. And variableName is the name of the variable you want to store the user input in.

2. In the date command, I've specified a date format.
In this case, %a is the short day name (e.g. Sun instead of Sunday) and then %e/%m/%Y is the date in dd/mm/yyyy format.

So your log-file entries should look something like this:
Code:
Fri 17/11/2023 - Funny cat compilation
https://www.youtube.com/someVideoLinK

Fri 17/11/2023 - Badgers with guns
https://www.youtube.com/NotARealURL
NOTE: The URLS above are NOT valid URLS - it was just a contrived example, to show you what the log output from the command I've given SHOULD yield.
I say SHOULD because I haven't actually tested the alias As long as I haven't made any silly typos it should work. I'm 99.99% sure it will work flawlessly. Ha ha!

This thread has actually given me some interesting ideas for a script which could allow you to download a list of videos in a single batch. Logging download information to a history file..
And to speed up batch downloads, it could use GNU parallel to download multiple videos at once. Hmmmm..... I might get started on that after work this evening, whilst my partner is out at Wells carnival with her grandson.
 

Members online


Top