Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement insectrc (closes #107) #248

Merged
merged 1 commit into from
Feb 13, 2021
Merged

Conversation

Mstrodl
Copy link
Contributor

@Mstrodl Mstrodl commented Feb 9, 2021

On startup, insect will read and execute ~/.insectrc before evaluating anything. If this behaviour isn't desired, the user can simply set the INSECT_NO_RC environment variable to true to disable it.

This is useful for a few reasons. Personally, I'm using it to keep some commonly-used functions:

cosecant(x)=1/sin(x)
csc(x)=cosecant(x)

secant(x)=1/cos(x)

cotangent(x)=1/tan(x)
cot(x)=cotangent(x)

@sharkdp sharkdp merged commit f2a837d into sharkdp:master Feb 13, 2021
@sharkdp
Copy link
Owner

sharkdp commented Feb 13, 2021

Awesome, thank you very much for your contribution!

@davidrihtarsic
Copy link

Hi,
can you help me with the implementation of .insectrc?
I'm using insect from AUR:

╰> pacman -Qi insect
Name            : insect
Version         : 5.6.0-2
...

I have created the .insectrc file in my home dir.:

╰> ls -al ~/.ins*
-rw-r--r-- 1 david users 48 Sep 30 10:10 /home/david/.insectrc

with the content:

╰> cat .insectrc
set displayed_digits 10
set prompt "insect >>>"

when I run insect nothing is changed

╰> insect
>>> pi
  pi
   = 3.14159

... so, what am I doing wrong?

@Mstrodl
Copy link
Contributor Author

Mstrodl commented Sep 30, 2021

@davidrihtarsic your insectrc is not a valid expression:
image

@davidrihtarsic
Copy link

davidrihtarsic commented Sep 30, 2021

@Mstrodl thx for the answer. OK, fair enough... I changed the content in .insectrc to:

╰> cat .insectrc
multi(x,y)=x*y

... but when I run insect, the function is not working:

╰> insect
>>> multi(2,3)
  Parse error at position 8: Expected ")"
>>>

However, if I run these commands inside insect, I get these results:

╰> insect
>>> multi(x,y)=x*y
  multi(x, y) = x × y
>>> multi(2,3)
  multi(2, 3)
   = 6
>>>

I really love insect, I use it on a daily basis, but it would be very nice to have some personal functions inside. Does anyone knows if there is a way to run it in debug mode e.g.:

insect --verbose

... do you have any other ideas?

@sharkdp
Copy link
Owner

sharkdp commented Sep 30, 2021

How did you install insect? I guess I haven't released a new version since this feature was merged.

@davidrihtarsic
Copy link

@sharkdp thx for your comment.
As I wrote, I'm using insect from AUR (on Linux) and currently running version: 5.6.0-2. OK, if this feature is not jet available I'll wait and I look forward to it.

@sharkdp
Copy link
Owner

sharkdp commented Mar 25, 2022

This is now available in v5.7.0. I also updated the insect package on AUR. Let me know if this works, @davidrihtarsic

@gennaro-tedesco
Copy link

Very excited to have the .insectrc! Do we have some lines of documentation somewhere that indicate the grammar for it or does it simply accept any insect valid expression?

@sharkdp
Copy link
Owner

sharkdp commented Mar 28, 2022

Do we have some lines of documentation somewhere that indicate the grammar for it or does it simply accept any insect valid expression?

The latter, correct. There's nothing special about the insectrc environment.

@gennaro-tedesco
Copy link

The latter, correct. There's nothing special about the insectrc environment.

Great, thank you. If I understand correctly, however, the keyword set(as per #107) is not implemented yet, is it (which makes the .insectrc at the moment only accepting user-defined functions)?

@sharkdp
Copy link
Owner

sharkdp commented Apr 2, 2022

Oh, right. I'll reopen that ticket.

which makes the .insectrc at the moment only accepting user-defined functions

.. and variables, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants