My build of nnn with minor changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 line
766 B

  1. #!/usr/bin/env sh
  2. # Description: Fuzzy find a command from history, edit in $EDITOR and run as a command
  3. # Currently supports only bash and fish history
  4. #
  5. # Shell: POSIX compliant
  6. # Author: Arun Prakash Jana
  7. shellname="$(basename "$SHELL")"
  8. if [ "$shellname" = "bash" ]; then
  9. hist_file="$HOME/.bash_history"
  10. entry="$(fzy < "$hist_file")"
  11. elif [ "$shellname" = "fish" ]; then
  12. hist_file="$HOME/.config/fish/fish_history"
  13. entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | fzy)"
  14. fi
  15. if ! [ -z "$entry" ]; then
  16. tmpfile=$(mktemp)
  17. echo "$entry" >> "$tmpfile"
  18. $EDITOR "$tmpfile"
  19. if [ -s "$tmpfile" ]; then
  20. $SHELL -c "$(cat "$tmpfile")"
  21. fi
  22. rm "$tmpfile"
  23. printf "Press any key to exit"
  24. read -r _
  25. fi