How to execute a command/script after a specific command was executed?

InvisibleShadowGhost

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?

pLumo

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I detect a command is being executed and then execute an additional command after the current command

From Dev

How to execute a command specific to a file?

From Dev

How to view a specific command executed in terminal by time?

From Dev

How to execute 'clear' bash command before any other command is executed?

From Dev

How to fire alert after sql command executed?

From Dev

Will 'at' command be executed after the reboot?

From Dev

how to execute somecode after resolve or reject are executed in Promise

From Dev

How to write a code that will execute after each step is executed

From Dev

How to execute a specific command on opening a terminal

From Dev

How do I execute a command on a specific screen?

From Dev

How execute specific command from shell script

From Dev

how to execute code after yylex(); command

From Dev

how to execute a command after resume from suspend?

From Dev

How to immediately execute a command after creating a Screen?

From Dev

(All variants) How to execute specific command with any command entered?

From Dev

How to execute one specific command from history command?

From Dev

Batch command after loop is not executed

From Dev

Execute command for a specific output of a command

From Dev

how to execute command after current running command in bash?

From Dev

How to execute command after grep match on output of first command

From Dev

How to execute specific JavaScript to enable specific panel after postback

From Dev

jQuery: execute a function AFTER toggleClass was executed

From Dev

jQuery: execute a function AFTER toggleClass was executed

From Dev

Execute a controller after main controller is executed

From Dev

How to direct to file folder and execute specific file using batch command

From Dev

After command execution, how to determine whether an exit code has been set by bash or by the executed command?

From Dev

How do I save the output of last executed command in terminal after normally executing a command?

From Dev

Execute command on specific screen on CentOS

From Dev

How to execute command after opening new tmux session

Related Related

  1. 1

    How do I detect a command is being executed and then execute an additional command after the current command

  2. 2

    How to execute a command specific to a file?

  3. 3

    How to view a specific command executed in terminal by time?

  4. 4

    How to execute 'clear' bash command before any other command is executed?

  5. 5

    How to fire alert after sql command executed?

  6. 6

    Will 'at' command be executed after the reboot?

  7. 7

    how to execute somecode after resolve or reject are executed in Promise

  8. 8

    How to write a code that will execute after each step is executed

  9. 9

    How to execute a specific command on opening a terminal

  10. 10

    How do I execute a command on a specific screen?

  11. 11

    How execute specific command from shell script

  12. 12

    how to execute code after yylex(); command

  13. 13

    how to execute a command after resume from suspend?

  14. 14

    How to immediately execute a command after creating a Screen?

  15. 15

    (All variants) How to execute specific command with any command entered?

  16. 16

    How to execute one specific command from history command?

  17. 17

    Batch command after loop is not executed

  18. 18

    Execute command for a specific output of a command

  19. 19

    how to execute command after current running command in bash?

  20. 20

    How to execute command after grep match on output of first command

  21. 21

    How to execute specific JavaScript to enable specific panel after postback

  22. 22

    jQuery: execute a function AFTER toggleClass was executed

  23. 23

    jQuery: execute a function AFTER toggleClass was executed

  24. 24

    Execute a controller after main controller is executed

  25. 25

    How to direct to file folder and execute specific file using batch command

  26. 26

    After command execution, how to determine whether an exit code has been set by bash or by the executed command?

  27. 27

    How do I save the output of last executed command in terminal after normally executing a command?

  28. 28

    Execute command on specific screen on CentOS

  29. 29

    How to execute command after opening new tmux session

HotTag

Archive