Skip Navigation

.bin/check_installed.sh:fc:3: no such event: 1 when trying to run a set of commands from script that work fine when ran in the terminal directly

Hello everyone. I wrote this command in the terminal directly and got the desired and expected output - that being the last 50 occurrences of me installing or removing a package with pacman or yay: history | grep -e 'pacman -S\s' -e 'pacman -R\s' -e 'yay -S\s' -e 'yay -R\s' | tail -n 50 > ~/history_installed

I now want to make this runnable as a script for obvious reasons, but when add it to a script and run it I get the following error: /home/user/.bin/check_installed.sh:fc:3: no such event: 1

Here is my entire script:

#!/bin/zsh

{history | grep -e 'pacman -S\s' -e 'pacman -R\s' -e 'yay -S\s' -e 'yay -R\s' | tail -n 50} > ~/history_installed

Note: /home/user/.bin is in my path. Verified by successfully running another script in there from a different location.

Please help me figure this out if you could. I am running zsh with oh-my-zsh. Thanks in advance!

0
0 comments