How to preserve the order of the output of the command when piping to fzf

Viewed 34

I have bash function that allows me to copy a line from history. Here's the function

history_cp() {
  history | 
    sort --reverse --numeric-sort | 
    fzf | 
    awk '{ $1=""; print }' | 
    tr -s ' ' | 
    xclip -selection clipboard 
}

It works fine, but fzf doesn't maintain the order of the results, how do i keep the sorted results?

0 Answers
Related