Can I view my old .zsh_history outputs - output

I feel like someone would have asked this question before, however, I cannot find anything and it may be because it's too obvious and I'm looking in the wrong file or I'm not searching a good key term to find out.
I want to view some of my old output in the terminal (OSX) and I assumed that was stored in my .zsh_history and all I'm seeing is all my input without the outputs.
Is there a way I can go back and view this?
Is there a way I can save it for future use if not?

This is not zsh specific, It applies to most of the shells
If you executed the commands with output redirection,
like
someCommand > someFile.txt
or appended command output like this,
someCommand >> someFile.txt
They will be stored to the specific file. Else you would have to run each command again
This may solve your issue

Related

Using write access in Open command in TCL

How can i use write ('w') and read ('r') access while using command pipeline in open command in TCL.
when i do something like :
set f1 [open "| ls -l" w]
it returns a file descriptor to write to , say file1.
Now I am confused how can I put this file descriptor to my use.
PS : My example might be wrong, and in that case it'd be ideal if answer includes a programming example so that it'll be more clear.
Thanks
In general, the key things you can do with a channel are write to it (using puts), read from it (using gets and read), and close it. Obviously, you can only write to it if it is writable, and only read from it if it is readable.
When you write to a channel that is implemented as a pipeline, you send data to the program on the other end of the pipe; that's usually consuming it as its standard input. Not all programs do that; ls is one of the ones that completely ignores its standard input.
But the other thing you can do, as I said above, is close the channel. When you close a pipeline, Tcl waits for all the subprocesses to terminate (if they haven't already) and collects their standard error output, which becomes an error message from close if there is anything. (The errors are just like those you can get from calling exec; the underlying machinery is shared.)
There's no real point in running ls in a pure writable pipeline, at least not unless you redirect its output. Its whole purpose is to produce output (the sorted list of files, together with extra details with the -l option). If you want to get the output, you'll need a readable channel (readable from the perspective of Tcl): open "| ls -l" r. Then you'll be able to use gets $f1 to read a line from the subprocess.
But since ls is entirely non-interactive and almost always has a very quick running time (unless your directories are huge or you pass the options to enable recursion), you might as well just use exec. This does not apply to other programs. Not necessarily anyway; you need to understand what's going on.
If you want to experiment with pipelines, try using sort -u as the subprocess. That takes input and produces output, and exhibits all sorts of annoying behaviour along the way! Understanding how to work with it will teach you a lot about how program automation can be tricky despite it really being very simple.

GNU Octave Save entire workspace

I can save individual variables fine in Octave, but i'm stuck when it comes to saving the entire workspace (ie, the whole screen with everything I've written on it)
eg
save file1
load file1
Doesn't seem to do anything
Any help greatly appreciated
David B
I do not think what you describe is a feature within Octave. You can save variables and the command history, see the description linked below, but I don't think its possible to save "the whole screen with everything I've written on it". Maybe if you better describe what elements you'd like to recover, specific instructions could be given.
Note that you aren't creating a "math document" like in Mathematica or GNU Maxima. This is a command interpreter, and recording commands entered and variables used is the usual extent of things to save.
https://phoxis.org/2013/04/06/save-work-environment-in-octave/

File won't open in Fortran

I am trying to open a csv file in fortran but it won't display. I used the following command
open(unit=13, file='C:\\Users\\Smith Family\\Desktop\\Lifetables2.csv')
All I mean is that when I execute this command, nothing happens. There is no output whatsoever. Perhaps I am wrong but I thought that when you use the open command, the file would appear as output. Sorry, I'm a newbie to Fortran.
There is no output supposed to happen after executing the open statement. Output happens after print or write, never after just open.
What open does is to open the file for access by other statements like read or write so that you can read something from the file, then do something with the values you read and then perhaps write something on the screen. Or to write something into the file.
Read other questions and answers here for examples, but be sure to open a textbook or tutorial and really study the basics. Programming is quite hard, you have to study from some resource. You cannot just do trial and error.
See
Read data from a .csv file in fortran
and many other related questions and answers, but I can guarantee you they will be too dificult to understand unless you study the basics.

Is it possible to write a mercurial hook which would replace a certain macro pattern with the respective revision?

Suppose, I have the following pattern in a comment in my code - $REV$. I would like to have a client side hook, which would replace it with something like $REV[$ d3d004be40c5 $]REV$. Any subsequent commits would assume that there is a revision between $REV[$ and $]REV$ and replace it accordingly.
I want to use a client side hook, because I do not want an extra commit for this mangling, hence it must be done on the client as part of the commit.
I reckon a precommit hook in python should be apt for the job, but I've just thought to seek for an advice before delving into it. Maybe there is a better way to do it like using an existing extension, for instance. If anyone has done anything similar - please share.
Thanks.
P.S.
I know this may seem strange to embed the revision within the source code, but please indulge me.
keyword extension does what you want (though usefulness of this is really, really low).

How difficult would it be to add a message on 1000+ html files?

I have over 1000 html files that I need to edit in the exact same way. I need to;
Add a simple javascript code at the top of each file.
Put some kind of message at the top (it can be anything, as long as it displays the message I want it to).
I was wondering, do I have to edit each file manually to do this? Is there not .htaccess hacks or anything like that?
Any suggestions/help would be appreciated.
I you are using linux, or have installed Cygwin on windows, then sed may be the quickest way to edit the files.
Combined with find, it can be used to very quickly add (or indeed edit) many files.
For example, the following command will replace all instances of the word 'old' with 'new' in all .html files:
find . -name "*.html" -exec sed -i "s/old/new/g" '{}' \;
There are many other examples online.
You can use .htaccess to autoprepend some code, but to be honest, a global find/replace would be a better idea in many ways.
I don't know what OS you use, but as a Mac Developer, http://www.hexmonkeysoftware.com/ is a neat little tool that does find and replace over loads of files.
Otherwise, a quick python script would be easy to write to do this.
If there is any common structure to the files, and their content is valuable and going to be used further in some way, then I would consider going the opposite route and extracting all that information, storing it in a database (or something) and presenting it like normal. This would provide more flexibility in presentation, and could even make the data useful/usable in other ways.