My build of nnn with minor changes
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

39 lignes
845 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. if which fzf >/dev/null 2>&1; then
  8. fuzzy=fzf
  9. else
  10. exit 1
  11. fi
  12. shellname="$(basename "$SHELL")"
  13. if [ "$shellname" = "bash" ]; then
  14. hist_file="$HOME/.bash_history"
  15. entry="$("$fuzzy" < "$hist_file")"
  16. elif [ "$shellname" = "fish" ]; then
  17. hist_file="$HOME/.config/fish/fish_history"
  18. entry="$(grep "\- cmd: " "$hist_file" | cut -c 8- | "$fuzzy")"
  19. fi
  20. if ! [ -z "$entry" ]; then
  21. tmpfile=$(mktemp)
  22. echo "$entry" >> "$tmpfile"
  23. $EDITOR "$tmpfile"
  24. if [ -s "$tmpfile" ]; then
  25. $SHELL -c "$(cat "$tmpfile")"
  26. fi
  27. rm "$tmpfile"
  28. printf "Press any key to exit"
  29. read -r _
  30. fi