Ask Your Question
1

Is it possible to define commands permanently ?

asked 2 years ago

Busterbie gravatar image

updated 2 years ago

FrédéricC gravatar image

Hi! Just got started with Sage.

Alot of commands in Sage are quite verbose and long like "numerical_approx" or "cartesian_product". This might make things more accesible, but it does make the workflow quite slow and cluttered IMO. Is it possible to define new commands in Sage that will always be loaded everytime i open the console? Really i'm just trying to create permanent shorthand versions of existing commands.

In a less ideal, but still suitable solution: Is it possible to make a library that you can then load in the console? Then i could just load it everytime i start the console with one line of code.

Kind regards Buster

Preview: (hide)

Comments

In addition to adding commands in init.sage, I recommend using the TAB key frequently. You rarely need to type in the whole command. Also, the latest beta release (and so upcoming in an official release) includes an upgraded version of IPython, giving access to its "autosuggestions": https://ipython.readthedocs.io/en/sta....

John Palmieri gravatar imageJohn Palmieri ( 2 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 2 years ago

tmonteil gravatar image

updated 2 years ago

Yes, you can put the command in the file named init.sage within the ~/.sage/ directory (where ~ is your home directory).

If you want to load a file, you can use %load file.sage in the Sage console (or jupyer notebook).

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2 years ago

Seen: 181 times

Last updated: Aug 29 '22