install-nv-code.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #!/bin/bash
  2. set -o nounset # error when referencing undefined variable
  3. set -o errexit # exit when command fails
  4. installnodemac() { \
  5. brew install lua
  6. brew install node
  7. brew install yarn
  8. }
  9. installnodeubuntu() { \
  10. sudo apt install nodejs
  11. sudo apt install npm
  12. }
  13. installnodearch() { \
  14. sudo pacman -S nodejs
  15. sudo pacman -S npm
  16. }
  17. installnode() { \
  18. echo "Installing node..."
  19. [ "$(uname)" == "Darwin" ] && installnodemac
  20. [ -n "$(uname -a | grep Ubuntu)" ] && installnodeubuntu
  21. [ -f "/etc/arch-release" ] && installnodearch
  22. [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported"
  23. sudo npm i -g neovim
  24. }
  25. installpiponmac() { \
  26. sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
  27. python3 get-pip.py
  28. rm get-pip.py
  29. }
  30. installpiponubuntu() { \
  31. sudo apt install python3-pip > /dev/null
  32. }
  33. installpiponarch() { \
  34. pacman -S python-pip
  35. }
  36. installpip() { \
  37. echo "Installing pip..."
  38. [ "$(uname)" == "Darwin" ] && installpiponmac
  39. [ -n "$(uname -a | grep Ubuntu)" ] && installpiponubuntu
  40. [ -f "/etc/arch-release" ] && installpiponarch
  41. [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported"
  42. }
  43. installpynvim() { \
  44. echo "Installing pynvim..."
  45. pip3 install pynvim --user
  46. }
  47. cloneconfig() { \
  48. echo "Cloning NVCode configuration"
  49. git clone https://github.com/ChristianChiarulli/nvcode.git ~/.config/nvcode
  50. nvim --headless +PackSync +qall > /dev/null 2>&1
  51. }
  52. asktoinstallnode() { \
  53. echo "node not found"
  54. echo -n "Would you like to install node now (y/n)? "
  55. read answer
  56. [ "$answer" != "${answer#[Yy]}" ] && installnode
  57. }
  58. asktoinstallpip() { \
  59. # echo "pip not found"
  60. # echo -n "Would you like to install pip now (y/n)? "
  61. # read answer
  62. # [ "$answer" != "${answer#[Yy]}" ] && installpip
  63. echo "Please install pip3 before continuing with install"
  64. exit
  65. }
  66. installonmac() { \
  67. brew install ripgrep fzf ranger
  68. }
  69. pipinstallueberzug() { \
  70. which pip3 > /dev/null && pip3 install ueberzug || echo "Not installing ueberzug pip not found"
  71. }
  72. installonubuntu() { \
  73. sudo apt install ripgrep fzf ranger
  74. sudo apt install libjpeg8-dev zlib1g-dev python-dev python3-dev libxtst-dev
  75. pip3 install ueberzug
  76. pip3 install neovim-remote
  77. }
  78. installonarch() { \
  79. sudo pacman -S install ripgrep fzf ranger
  80. which yay > /dev/null && yay -S python-ueberzug-git || pipinstallueberzug
  81. pip3 install neovim-remote
  82. }
  83. installextrapackages() { \
  84. [ "$(uname)" == "Darwin" ] && installonmac
  85. [ -n "$(uname -a | grep Ubuntu)" ] && installonubuntu
  86. [ -f "/etc/arch-release" ] && installonarch
  87. [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ] && echo "Windows not currently supported"
  88. }
  89. # Welcome
  90. echo 'Installing NVCode'
  91. # install pip
  92. which pip3 > /dev/null && echo "pip installed, moving on..." || asktoinstallpip
  93. # install node and neovim support
  94. which node > /dev/null && echo "node installed, moving on..." || asktoinstallnode
  95. # install pynvim
  96. pip3 list | grep pynvim > /dev/null && echo "pynvim installed, moving on..." || installpynvim
  97. # move old nvim directory if it exists
  98. # [ -d "$HOME/.config/nvim" ] && moveoldnvim
  99. # clone config down
  100. cloneconfig
  101. echo 'export PATH=/home/$USER/.config/nvcode/utils/bin:$PATH' >> ~/.zshrc
  102. echo 'export PATH=/home/$USER/.config/nvcode/utils/bin:$PATH' >> ~/.bashrc
  103. echo "I recommend you also install and activate a font from here: https://github.com/ryanoasis/nerd-fonts"
  104. echo "I also recommend you add 'set preview_images_method ueberzug' to ~/.config/ranger/rc.conf"
  105. echo 'export PATH=/home/$USER/.config/nvcode/utils/bin:$PATH appending to zshrc/bashrc'