Reputation: 50
I made a bash function which retrieves a list of cron tasks (from Magento). I can search through that (filtered) list immediately using FZF and it runs the selected cron using another command through xargs. The function is as follows:
crf () { magerun2 sys:cr:li | grep -E '\*|-' | grep -v '+' | awk '{print $2}' | fzf --query=$1 | xargs magerun2 sys:cr:run; }
Is it possible to add the command which just ran through xargs to the history so when i press the up
arrow it will show the command which has just passed through xargs?
I'm running on a Macbook Pro, using bash version 5.0.11(1)-release (x86_64-apple-darwin18.6.0) and tmux 3.0.
Upvotes: 1
Views: 202
Reputation: 2093
Yes, using history -s
$ history -s my command
<PRESS UP KEY>
$ my command
EDIT: So in your case itll be something like
crf () {
CHRON=$(magerun2 sys:cr:li | grep -E '\*|-' | grep -v '+' | awk '{print $2}' | fzf --query=$1 )
for item in $CHRON ; do
history -s $item
magerun2 sys:cr:run $item
done
}
Upvotes: 3