Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+0 −0
Q&A How can I simply persist functions written in the current terminal session for later use?

For functions, you could dump all currently-defined functions to a file such as appending to ~/.bashrc. typeset -f >> ~/.bashrc Note that this specifically will display every function, re...

posted 22d ago by bgstack15‭

Answer
#1: Initial revision by user avatar bgstack15‭ · 2024-12-27T17:54:40Z (22 days ago)
For functions, you could dump all currently-defined functions to a file such as appending to `~/.bashrc`.
```
typeset -f >> ~/.bashrc
```
Note that this specifically will display every function, regardless of where it was defined. So you would have to manually remove duplicates/unwanted entries.

You could also bother to save that output to a "full" file, and compare it to the output of a new shell.
```
bash -i -c 'typeset -f' > ~/funcs-plain
typeset -f > ~/funcs-mine
```
And then diff them for easy comparison.