Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in or
create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision |
Your text |
Line 24: |
Line 24: |
|
| |
|
| This is a list of tiny helper functions (the equivalent of e.g., shell aliases), the kind one would have on its {{Path|.octaverc}} file. | | This is a list of tiny helper functions (the equivalent of e.g., shell aliases), the kind one would have on its {{Path|.octaverc}} file. |
|
| |
| === Reload 'octave.rc' after 'clear' ===
| |
| When using {{Codeline|clear}}, one may accidentally remove functions (alias) or other variables set on the {{Path|octave.rc}} file. This can fixed by shadowing the {{Codeline|clear}} function with the following:
| |
|
| |
| {{Code|reload octave.rc after clear|<pre>
| |
| function clear (varargin)
| |
| args = sprintf (', "%s"', varargin{:});
| |
| evalin ("caller", ['builtin ("clear"' args ')']);
| |
| source ("~/.octaverc");
| |
| endfunction</pre>}}
| |
|
| |
| The problem with this approach is if there's path manipulation on the {{Path|octave.rc}} file, such as {{Codeline|addpath}}. A workaround is needed for each case since it is not possible to obtain a reliable list of what's in Octave load path. But basically should be to undo what the file does, before {{Codeline|source ("~/.octaverc")}}.
| |
|
| |
| If there's a {{Codeline|pkg unload all}} on it, this would also unload all packages. The following adjustment will keep the packages loaded
| |
|
| |
| {{Code|reload octave.rc after clear but keep packages loaded|<pre>
| |
| function clear (varargin)
| |
| args = sprintf (', "%s"', varargin{:});
| |
| evalin ("caller", ['builtin ("clear"' args ')']);
| |
| pkglist = pkg ("list");
| |
| loadedpkg = cell (0);
| |
| for ii = 1:numel (pkglist)
| |
| if (pkglist{ii}.loaded)
| |
| loadedpkg{end+1} = pkglist{ii}.name;
| |
| endif
| |
| endfor
| |
| source ("~/.octaverc");
| |
| if (numel (loadedpkg) != 0)
| |
| pkg ("load", loadedpkg{:});
| |
| endif
| |
| endfunction</pre>}}
| |
|
| |
|
| |
|
| === replace help with man === | | === replace help with man === |