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.

getplugs 1.5 KiB

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