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.
 
 
 
 
 
 

69 lignes
1.4 KiB

  1. #!/usr/bin/env sh
  2. # Description: Update nnn plugins
  3. #
  4. # Shell: POSIX compliant
  5. # Author: Arun Prakash Jana, KlzXS
  6. CONFIG_DIR=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/
  7. PLUGIN_DIR=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins
  8. is_cmd_exists () {
  9. which "$1" > /dev/null 2>&1
  10. echo $?
  11. }
  12. merge () {
  13. vimdiff +0 "$1" "$2"
  14. }
  15. prompt () {
  16. printf "%s" "Plugin $1 already exists and is different.\n"
  17. printf "Keep (k), merge (m), overwrite (o) [default: k]? "
  18. read -r operation
  19. if [ "$operation" = "m" ]; then
  20. op="merge"
  21. elif [ "$operation" = "o" ]; then
  22. op="cp -vRf"
  23. else
  24. op="true"
  25. fi
  26. }
  27. # if [ "$(is_cmd_exists sudo)" -eq "0" ]; then
  28. # sucmd=sudo
  29. # elif [ "$(is_cmd_exists doas)" -eq "0" ]; then
  30. # sucmd=doas
  31. # else
  32. # sucmd=: # noop
  33. # fi
  34. # backup any earlier plugins
  35. if [ -d "$PLUGIN_DIR" ]; then
  36. tar -C "$CONFIG_DIR" -czf "$CONFIG_DIR""plugins-$(date '+%Y%m%d%H%M').tar.gz" plugins/
  37. fi
  38. mkdir -p "$PLUGIN_DIR"
  39. cd "$CONFIG_DIR" || exit 1
  40. curl -Ls -O https://github.com/jarun/nnn/archive/master.tar.gz
  41. tar -zxf master.tar.gz
  42. cd nnn-master/plugins || exit 1
  43. # shellcheck disable=SC2044
  44. # We do not use obnoxious names for plugins
  45. for f in $(find . -maxdepth 1 \( ! -iname "." ! -iname "*.md" \)); do
  46. if [ -f ../../plugins/"$f" ]; then
  47. if [ "$(diff --brief "$f" ../../plugins/"$f")" ]; then
  48. prompt "$f"
  49. $op "$f" ../../plugins/
  50. fi
  51. else
  52. cp -vRf "$f" ../../plugins/
  53. fi
  54. done
  55. cd ../.. || exit 1
  56. rm -rf nnn-master/ master.tar.gz