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.
 
 
 
 
 
 

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