I have a tiny script which generates aliases for the execution of flatpak packages (to make flatpaks somehow usable from the command line). When I run this command by hand, everything works fine.
But instead of always executing this command by hand after each flatpak install/update/remove I want my script to be executed automatically every time after the flatpak command was invoked.
So, to make a bit more clear effectively I need commands flatpak *
to be rewritten to flatpak * && ~/my_script.sh
.
Bonus: How could I restrict this function to only call the script if flatpak install
or flatpak remove
was called but not when flatpak list
for example?
Does anyone have an idea how to achieve this?
You can create an alias
and add that to your .bashrc
:
alias flatpak='flatpak_(){ flatpak "$@" && ~/my_script.sh; }; flatpak_'
To only execute my_script
if first argument was install
or remove
:
alias flatpak='flatpak_(){ flatpak "$@" && [[ "$1" = install || "$1" = remove ]] && ~/my_script.sh; }; flatpak_'
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments