It's not totally clear to me what you want, but if I understand correctly you want:
- to comfortably look through the history of used terminal commands
- selectively save them to a script for re-use
To achieve 1 this answer already has an explanation.
Objective 2 can be achieved by simply copy pasting the desired commands from the
Or, if you have some commands that you use often you could create an alias. That is a sort of short cut to a certain command. A permanent alias can be created in the
~/.profile must then be loaded at every startup of Terminal.app. To achieve that go to the Terminal preferences and fill in
source ~/.profile in run command at startup field:
An example of aliases I have in my
~/.profile file are shown below
alias showinvisibles="defaults write com.apple.finder AppleShowAllFiles YES"
alias hideinvisibles="defaults write com.apple.finder AppleShowAllFiles NO"
Now, whenever I type
showinvisibles actually the command
defaults write com.apple.finder AppleShowAllFiles YES is executed.