aboutsummaryrefslogtreecommitdiffstats
path: root/tools/compile_vim.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/compile_vim.sh')
-rwxr-xr-xtools/compile_vim.sh94
1 files changed, 94 insertions, 0 deletions
diff --git a/tools/compile_vim.sh b/tools/compile_vim.sh
new file mode 100755
index 0000000..47115a9
--- /dev/null
+++ b/tools/compile_vim.sh
@@ -0,0 +1,94 @@
1#!/bin/bash
2
3set -e # exit when error
4# environment variables here
5
6VIMRUNTIME=/usr/share/vim/vim91
7color_file=industry.vim
8
9# write a function to install sth,the parameter of the func is the packages
10function install() {
11 sudo apt update
12 sudo apt upgrade
13 sudo apt remove vim*
14 sudo apt install -y git libatk1.0-dev libcairo2-dev liblua5.1-0-dev \
15 libncurses5-dev libperl-dev libx11-dev libxpm-dev \
16 libxt-dev lua5.1 python3-dev ruby-dev
17 }
18
19# check current user is root or not, if is, warn the user
20if [ $UID -eq 0 ]; then
21 echo -e "\033[31mYou are root, I recommand to use a normal user to run this script.\033[0m"
22 exit
23fi
24
25cd ~
26# if this is the first time to compile vim
27if [ $# -eq 1 ] && [ $1 == "first" ]; then
28 install
29 if ! [ -d app ]; then
30 mkdir app
31 fi
32 cd app
33 echo -e "\033[32mGetting vim source code...\033[0m"
34 git clone https://github.com/vim/vim
35 cd vim/src
36else
37 cd app/vim/src
38 sudo make uninstall
39 make distclean
40 echo -e "\033[32mGetting vim source code...\033[0m"
41 git pull
42fi
43
44# get the default python version
45python_version=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1"."$2}')
46if [ -z $python_version ]; then
47 echo -e "\033[31mInstalling python3...\033[0m"
48 sudo apt update && sudo apt upgrade
49 sudo apt install python3
50 python_version=$(python3 -V 2>&1 | awk '{print $2}' | awk -F '.' '{print $1"."$2}')
51fi
52# if gtk installed, remove it
53if [ -d /usr/local/include/gtk-2.0 ]; then
54 sudo apt remove libgtk2.0-dev
55fi
56
57echo -e "\033[32mPython version: $python_version\033[0m"
58
59echo -e "\033[32mConfiguring compile environment...\033[0m"
60./configure \
61 --with-features=huge \
62 --enable-multibyte \
63 --enable-rubyinterp=dynamic \
64 --with-ruby-command=/usr/bin/ruby \
65 --enable-luainterp\
66 --enable-python3interp=dynamic \
67 --with-python3-command=$(which python$python_version) \
68 --with-python3-config-dir=$(python$python_version-config --configdir) \
69 --enable-perlinterp=dynamic \
70 --enable-largefile \
71 --enable-cscope \
72 --with-compiledby="An Ordinary Communist weunite1848@gmail.com" \
73 --enable-fail-if-missing \
74 --disable-gui \
75 --prefix=/usr
76
77echo -e "\033[32mCompiling vim...\033[0m"
78make
79
80echo -e "\033[32mInstalling vim...\033[0m"
81sudo make install
82
83echo -e "\033[32;36mCompile done!\033[0m"
84vim --version | head -n 3
85
86# test if the terminal support 256 colors, if so, configure the color file
87if [ $(tput colors) -ge 256 ]; then
88 color_file=$VIMRUNTIME/colors/$color_file
89 echo -e "\033[32mConfiguring $color_file as transparent...\033[0m"
90 sudo sed -i '/if s:t_Co >= 256/,/hi Normal/{s/hi Normal/" hi/}' $color_file
91 sudo sed -i '/if s:t_Co >= 256/,/hi EndOfBuffer/{s/hi EndOfBuffer/" hi/}' $color_file
92fi
93
94echo -e "\033[32;36mDone.\033[0m"