Skip to main content

Timeline for answer to How to save a function in bash for later use? by igal

Current License: CC BY-SA 3.0

Post Revisions

18 events
when toggle format what by license comment
Nov 15, 2017 at 13:16 comment added igal @SergiyKolodyazhnyy Actually, maybe I do understand what you're asking. If you want to add a previously declared function to your ~/.bashrc you could use the type or declare -f commands. They will output the function definition. So you could do something like declare -f myfunction >> ~/.bashrc to append the function definition for myfunction to the ~/.bashrc file.
Nov 15, 2017 at 13:10 comment added igal @SergiyKolodyazhnyy I'm not sure what you mean by "dump" what's in ~/.bashrc. I wouldn't say that ~/.bashrc is the "manual way" of doing anything, since it's run automatically (under the appropriate conditions).
Nov 15, 2017 at 8:33 comment added Sergiy Kolodyazhnyy So just to clarify: there's no way to dump what's already defined into ~/.bashrc ( or any other file for that matter ) ? Manual way only?
Nov 15, 2017 at 6:14 comment added igal @Arrow Hmmm. I don't see anything there that says that ~/bin has been designated for user scripts, except by recent versions of Ubuntu.
Nov 14, 2017 at 22:26 comment added user232326 It is a function of how $PATH is built read this.
Nov 14, 2017 at 22:24 history edited igal CC BY-SA 3.0
added 104 characters in body
Nov 14, 2017 at 22:23 comment added igal @Arrow I didn't know that. Is there a reference for that?
Nov 14, 2017 at 22:22 comment added user232326 The path /home/user/bin is designed for user scripts. You may add this.
Nov 14, 2017 at 22:21 comment added igal @HrvojeT If you have the time and the inclination, you might want to create a temporary user and populate all of their shell initialization and profile files with echo statements, and then open shell windows in various ways, e.g. launch your terminal application, open a new tab, open a new window, run a command in a subshell, etc. That way you can watch and see the order in which the different files are loaded. I remember finding that very instructive.
Nov 14, 2017 at 22:19 comment added Hrvoje T I saved it in .bashrc. Had to reopen a terminal to load that config. Now it works, thanks to both very much
Nov 14, 2017 at 22:17 history edited igal CC BY-SA 3.0
added 228 characters in body
Nov 14, 2017 at 22:12 comment added igal @StéphaneChazelas Sorry, Mac user here. Thanks for the comment. I updated my solution. Is that better?
Nov 14, 2017 at 22:12 history edited igal CC BY-SA 3.0
added 983 characters in body; deleted 44 characters in body; added 4 characters in body
Nov 14, 2017 at 22:08 vote accept Hrvoje T
Nov 14, 2017 at 21:54 history edited igal CC BY-SA 3.0
added 209 characters in body
Nov 14, 2017 at 21:53 comment added Stéphane Chazelas ~/.profile is to configure your login session, not your shell. Only the login shell reads that file. bash customisation goes in ~/.bashrc
Nov 14, 2017 at 21:51 history edited igal CC BY-SA 3.0
deleted 2 characters in body
Nov 14, 2017 at 21:43 history answered igal CC BY-SA 3.0