Update setup-vim.sh for better shared configs using /etc/skel/ and /etc/vim/. Plugins, managers are installed and shared within /usr/share/vim/vimfiles/
This commit is contained in:
parent
14bfab8235
commit
b69b9c511f
|
@ -25,7 +25,18 @@ ln -s libclang.so.1 libclang.so
|
|||
- Allows the use of TAB to enable code-completion context menu
|
||||
-- https://github.com/ervandew/supertab
|
||||
|
||||
- Enable nocp
|
||||
-- Ensures vim is not set to be compatible with older versions of vi
|
||||
-- Removing this could diable enhancements on some systems
|
||||
-- :help 'compatible' within vim for more information
|
||||
|
||||
- Define backspace scope
|
||||
-- Ensures that backspace has the permissions to remove all character types
|
||||
|
||||
- Custom Keybindings
|
||||
- The keybind (Ctrl-e <ARROW KEY>) allows switching between split vim windows
|
||||
-- Ctrl-w is the default setting, which closes tabbed shells on Chrome OS
|
||||
|
||||
- Backups previous vimrc configurations
|
||||
-- If they were present, previous vim files are stored in /etc/config-vim/backups/
|
||||
|
||||
|
|
|
@ -29,52 +29,112 @@ I usually run this script within whatever directory I'm working in, hence the in
|
|||
setup-vim.sh
|
||||
------------
|
||||
|
||||
To use this script, copy it to a safe directory where we can store previous / future vimrc configurations and run it as a user with sudo privelages. See below for example commands and output.
|
||||
To use this script, run `sudo ./setup-vim.sh` as seen below. Vim configs used for this script are stored in `/etc/config-vim/`. When the script runs into previous vimrc configs they are backed up into `/etc/config-vim/backups/`
|
||||
|
||||
```bash
|
||||
|
||||
cloud_user@shaunrd02c:~$ pwd
|
||||
/home/cloud_user
|
||||
cloud_user@shaunrd02c:~$ ls
|
||||
klips
|
||||
cloud_user@shaunrd02c:~$ cp klips/scripts/setup-vim.sh .
|
||||
cloud_user@shaunrd02c:~$ ./setup-vim.sh
|
||||
cloud_user@shaunrd03c:~$ ./setup-vim.sh
|
||||
This script must be ran with sudo...
|
||||
sudo ./setup-vim.sh
|
||||
cloud_user@shaunrd03c:~$ sudo ./setup-vim.sh
|
||||
|
||||
Enter 1 to configure vim with the Klips repository, any other value to exit.
|
||||
The up-to-date .vimrc config can be found here: https://github.com/shaunrd0/klips/tree/master/configs
|
||||
Configuring Vim with this tool will update / upgrade your packages
|
||||
|
||||
|
||||
1
|
||||
|
||||
Updating, upgrading required packages...
|
||||
... ( Reduced output ) ...
|
||||
remote: Compressing objects: 100% (58/58), done.
|
||||
remote: Total 92 (delta 28), reused 79 (delta 18), pack-reused 0
|
||||
Unpacking objects: 100% (92/92), done.
|
||||
mkdir: created directory 'config-vim'
|
||||
renamed 'temp/README.md' -> 'config-vim/README.md'
|
||||
Hit:1 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic InRelease
|
||||
Hit:2 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-updates InRelease
|
||||
Hit:3 http://us-east-1.ec2.archive.ubuntu.com/ubuntu bionic-backports InRelease
|
||||
Hit:4 http://security.ubuntu.com/ubuntu bionic-security InRelease
|
||||
Reading package lists... Done
|
||||
Building dependency tree
|
||||
Reading state information... Done
|
||||
32 packages can be upgraded. Run 'apt list --upgradable' to see them.
|
||||
Reading package lists... Done
|
||||
Building dependency tree
|
||||
Reading state information... Done
|
||||
Calculating upgrade... Done
|
||||
The following packages were automatically installed and are no longer required:
|
||||
linux-aws-headers-4.15.0-1043 linux-headers-4.15.0-1043-aws linux-image-4.15.0-1043-aws
|
||||
linux-modules-4.15.0-1043-aws
|
||||
Use 'sudo apt autoremove' to remove them.
|
||||
The following packages will be upgraded:
|
||||
bind9-host bsdutils dnsutils dpkg dpkg-dev fdisk libbind9-160 libblkid1 libdns-export1100 libdns1100
|
||||
libdpkg-perl libfdisk1 libirs160 libisc-export169 libisc169 libisccc160 libisccfg160 libldap-2.4-2
|
||||
libldap-common liblwres160 libmount1 libprocps6 libsmartcols1 libsoup-gnome2.4-1 libsoup2.4-1
|
||||
libuuid1 mount procps snapd util-linux uuid-runtime xkb-data
|
||||
32 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
|
||||
Need to get 20.5 MB of archives.
|
||||
After this operation, 1001 kB of additional disk space will be used.
|
||||
Reading package lists... Done
|
||||
Building dependency tree
|
||||
Reading state information... Done
|
||||
git is already the newest version (1:2.17.1-1ubuntu0.4).
|
||||
vim is already the newest version (2:8.0.1453-1ubuntu1.1).
|
||||
The following packages were automatically installed and are no longer required:
|
||||
linux-aws-headers-4.15.0-1043 linux-headers-4.15.0-1043-aws linux-image-4.15.0-1043-aws
|
||||
linux-modules-4.15.0-1043-aws
|
||||
Use 'sudo apt autoremove' to remove them.
|
||||
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
|
||||
|
||||
Klips config files updatedmkdir: created directory 'config-vim/backup/'
|
||||
Gathering resources from Klips repository..
|
||||
Cloning into 'temp'...
|
||||
remote: Enumerating objects: 339, done.
|
||||
remote: Counting objects: 100% (339/339), done.
|
||||
remote: Compressing objects: 100% (221/221), done.
|
||||
remote: Total 339 (delta 135), reused 283 (delta 82), pack-reused 0
|
||||
Receiving objects: 100% (339/339), 59.76 KiB | 19.92 MiB/s, done.
|
||||
Resolving deltas: 100% (135/135), done.
|
||||
mkdir: created directory '/etc/config-vim'
|
||||
'temp/README.md' -> '/etc/config-vim/README.md'
|
||||
'temp/configs/' -> '/etc/config-vim/configs'
|
||||
'temp/configs/.vimrc' -> '/etc/config-vim/configs/.vimrc'
|
||||
'temp/configs/.vimrc-README' -> '/etc/config-vim/configs/.vimrc-README'
|
||||
'temp/configs/fail2ban' -> '/etc/config-vim/configs/fail2ban'
|
||||
'temp/configs/fail2ban/README.md' -> '/etc/config-vim/configs/fail2ban/README.md'
|
||||
'temp/configs/fail2ban/jail.local' -> '/etc/config-vim/configs/fail2ban/jail.local'
|
||||
'temp/configs/fail2ban/nginx-nohome.conf' -> '/etc/config-vim/configs/fail2ban/nginx-nohome.conf'
|
||||
'temp/configs/fail2ban/nginx-noproxy.conf' -> '/etc/config-vim/configs/fail2ban/nginx-noproxy.conf'
|
||||
'temp/configs/fail2ban/nginx-noscript.conf' -> '/etc/config-vim/configs/fail2ban/nginx-noscript.conf'
|
||||
|
||||
Backup directory created - /home/cloud_user/config-vim/backup/
|
||||
renamed '/home/cloud_user/.vimrc' -> 'config-vim/backup/.vimrc'
|
||||
Your local .vimrc has been stashed in /home/cloud_user/config-vim/backup/
|
||||
Klips configs gathered
|
||||
See /etc/config-vim/README.md for more information.
|
||||
|
||||
mkdir: created directory '/etc/config-vim/backup/'
|
||||
|
||||
Backup directory created - /etc/config-vim/backup/
|
||||
mv: cannot stat '/home/cloud_user/.vimrc': No such file or directory
|
||||
mv: cannot stat '/etc/skel/.vimrc': No such file or directory
|
||||
renamed '/usr/share/vim/vimrc' -> '/etc/config-vim/backup/share/vimrc'
|
||||
renamed '/etc/vim/vimrc' -> '/etc/config-vim/backup/etc/vimrc'
|
||||
Your local .vimrc configurations have been stashed in /etc/config-vim/backup/
|
||||
|
||||
New ~/.vimrc configuration installed.
|
||||
New /etc/skel/.vimrc configuration installed.
|
||||
New /etc/vim/vimrc configuration installed.
|
||||
|
||||
Removing any previous installations of Pathogen...
|
||||
|
||||
Installing Pathogen plugin manager for Vim....
|
||||
|
||||
If they don't exist, we will create the following directories:
|
||||
/usr/share/vim/vimfiles/autoload/ /usr/share/vim/vimfiles/bundle/mkdir: created directory '/usr/share/vim/vimfiles/autoload'
|
||||
mkdir: created directory '/usr/share/vim/vimfiles/bundle'
|
||||
|
||||
Pathogen has been installed! Plugins plugins can now be easily installed.
|
||||
|
||||
Removing plugins installed by this tool...
|
||||
rm: cannot remove '/usr/share/vim/vimfiles/bundle/*': No such file or directory
|
||||
/usr/share/vim/vimfiles/bundle ~
|
||||
|
||||
Installing updated plugins...
|
||||
Cloning into 'supertab'...
|
||||
remote: Enumerating objects: 687, done.
|
||||
remote: Total 687 (delta 0), reused 0 (delta 0), pack-reused 687
|
||||
Receiving objects: 100% (687/687), 186.15 KiB | 2.36 MiB/s, done.
|
||||
Receiving objects: 100% (687/687), 186.15 KiB | 20.68 MiB/s, done.
|
||||
Resolving deltas: 100% (267/267), done.
|
||||
|
||||
Supertab plugin has been installed
|
||||
|
@ -82,7 +142,7 @@ Supertab plugin has been installed
|
|||
Cloning into 'clang_complete'...
|
||||
remote: Enumerating objects: 2720, done.
|
||||
remote: Total 2720 (delta 0), reused 0 (delta 0), pack-reused 2720
|
||||
Receiving objects: 100% (2720/2720), 727.21 KiB | 2.04 MiB/s, done.
|
||||
Receiving objects: 100% (2720/2720), 725.96 KiB | 25.03 MiB/s, done.
|
||||
Resolving deltas: 100% (1132/1132), done.
|
||||
|
||||
Clang Completion plugin has been installed
|
||||
|
@ -91,6 +151,7 @@ Clang Completion plugin has been installed
|
|||
Vim has been configured with the Klips repository.
|
||||
|
||||
Configuration Changes:
|
||||
~
|
||||
Packages Installed / Updated:
|
||||
- vim, git, clang
|
||||
|
||||
|
@ -110,22 +171,29 @@ Plugin Settings:
|
|||
- Clang_complete vim plugin has been installed and .vimrc configured for its use.
|
||||
- Code-completion is enabled with default clang_complete settings
|
||||
-- https://github.com/xavierd/clang_complete
|
||||
--If you have issues with Clang_complete library linking / loading, check the directory / commands below -
|
||||
cd /usr/lib/x86_64-unknown-linux
|
||||
ln -s libclang.so.1 libclang.so
|
||||
|
||||
- Supertab vim plugin has been installed and .vimrc configured for its use.
|
||||
- Allows the use of TAB to enable code-completion context menu
|
||||
-- https://github.com/ervandew/supertab
|
||||
|
||||
cloud_user@shaunrd02c:~$ ls
|
||||
config-vim klips setup-vim.sh
|
||||
cloud_user@shaunrd02c:~$ ls -R config-vim/
|
||||
config-vim/:
|
||||
README.md backup configs
|
||||
- Enable nocp
|
||||
-- Ensures vim is not set to be compatible with older versions of vi
|
||||
-- Removing this could diable enhancements on some systems
|
||||
-- :help 'compatible' within vim for more information
|
||||
|
||||
config-vim/backup:
|
||||
- Define backspace scope
|
||||
-- Ensures that backspace has the permissions to remove all character types
|
||||
|
||||
config-vim/configs:
|
||||
cloud_user@shaunrd02c:~$
|
||||
- Custom Keybindings
|
||||
- The keybind (Ctrl-e <ARROW KEY>) allows switching between split vim windows
|
||||
-- Ctrl-w is the default setting, which closes tabbed shells on Chrome OS
|
||||
|
||||
- Backups previous vimrc configurations
|
||||
-- If they were present, previous vim files are stored in /etc/config-vim/backups/
|
||||
cloud_user@shaunrd03c:~$
|
||||
```
|
||||
|
||||
Now just open a file in vim to test things out
|
||||
|
|
|
@ -10,6 +10,11 @@ RED=$(tput setaf 1)
|
|||
UNDERLINE=$(tput smul)
|
||||
NORMAL=$(tput sgr0)
|
||||
|
||||
if [ "$(whoami)" != "root" ]; then
|
||||
echo "This script must be ran with sudo..."
|
||||
echo "sudo ./setup-vim.sh"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
welcome=( "\nEnter 1 to configure vim with the Klips repository, any other value to exit." \
|
||||
"The up-to-date .vimrc config can be found here: https://github.com/shaunrd0/klips/tree/master/configs" \
|
||||
|
@ -24,33 +29,37 @@ if [ $cChoice -eq 1 ] ; then
|
|||
sudo apt -y update && sudo apt -y upgrade
|
||||
sudo apt install vim git
|
||||
|
||||
printf "\nGathering resources from Klips repository..\n"
|
||||
# Clone klips repository in a temp directory
|
||||
git clone https://github.com/shaunrd0/klips temp/
|
||||
# Relocate the files we need and remove the temp directory
|
||||
sudo mkdir -pv /etc/config-vim
|
||||
sudo cp -fruv temp/README.md /etc/config-vim/
|
||||
|
||||
sudo cp -fruv temp/configs/ /etc/config-vim/
|
||||
|
||||
rm -Rf temp/
|
||||
printf "\n${GREEN}Klips config files updated"
|
||||
printf "\n${GREEN}Klips configs gathered"
|
||||
printf "\nSee /etc/config-vim/README.md for more information.${NORMAL}\n\n"
|
||||
|
||||
# Create backup dir for .vimrc
|
||||
# Create backup dir for .vimrc files
|
||||
sudo mkdir -pv /etc/config-vim/backup/
|
||||
printf "\n${GREEN}Backup directory created - /etc/config-vim/backup/${NORMAL}\n"
|
||||
|
||||
# Stash the current .vimrc
|
||||
sudo mv -bv ~/.vimrc /etc/config-vim/backup/
|
||||
printf "${RED}Your local .vimrc has been stashed in /etc/config-vim/backup/${NORMAL}\n\n"
|
||||
# Stash current .vimrc configs to protect loss of information
|
||||
sudo mkdir /etc/config-vim/backup/home/ && sudo mv -bv ~/.vimrc /etc/config-vim/backup/home/
|
||||
sudo mkdir /etc/config-vim/backup/skel/ && sudo mv -bv /etc/skel/.vimrc /etc/config-vim/backup/skel/.vimrc
|
||||
sudo mkdir /etc/config-vim/backup/share/ && sudo mv -bv /usr/share/vim/vimrc /etc/config-vim/backup/share/vimrc
|
||||
sudo mkdir /etc/config-vim/backup/etc/ && sudo mv -bv /etc/vim/vimrc /etc/config-vim/backup/etc/vimrc
|
||||
printf "${RED}Your local .vimrc configurations have been stashed in /etc/config-vim/backup/${NORMAL}\n\n"
|
||||
|
||||
# Copy our cloned config into the user home directory
|
||||
# Copy our cloned config into the active user home directory
|
||||
sudo cp /etc/config-vim/configs/.vimrc ~/
|
||||
printf "${GREEN}New ~/.vimrc configuration installed.${NORMAL}\n"
|
||||
|
||||
# Copy our cloned config into the global user directories
|
||||
sudo cp /etc/config-vim/configs/.vimrc /usr/share/vim/vimfiles/vimrc
|
||||
sudo cp /etc/config-vim/configs/.vimrc /etc/skel/.vimrc
|
||||
printf "${GREEN}New /etc/skel/.vimrc configuration installed.${NORMAL}\n"
|
||||
sudo cp /etc/config-vim/configs/.vimrc /etc/vim/vimrc
|
||||
printf "${GREEN}New /etc/vim/vimrc configuration installed.${NORMAL}\n"
|
||||
|
||||
|
||||
# Reinstall Pathogen plugin manager for vim
|
||||
# https://github.com/tpope/vim-pathogen
|
||||
|
@ -71,20 +80,19 @@ if [ $cChoice -eq 1 ] ; then
|
|||
sudo rm -R /usr/share/vim/vimfiles/bundle/*
|
||||
|
||||
# Clone plugin repos into pathogen plugin directory
|
||||
pushd /usr/share/vim/vimfiles/bundle/
|
||||
printf "\n${GREEN}Installing updated plugins...${NORMAL}\n"
|
||||
git clone https://github.com/ervandew/supertab /usr/share/vim/vimfiles/bundle/supertab && \
|
||||
git clone https://github.com/ervandew/supertab && \
|
||||
printf "\n${GREEN}Supertab plugin has been installed${NORMAL}\n\n" && \
|
||||
git clone https://github.com/xavierd/clang_complete /usr/share/vim/vimfiles/bundle/clang_complete && \
|
||||
git clone https://github.com/xavierd/clang_complete && \
|
||||
printf "\n${GREEN}Clang Completion plugin has been installed${NORMAL}\n\n"
|
||||
vimConf=( "\n${UNDERLINE}Vim has been configured with the Klips repository.${NORMAL}" \
|
||||
"\nConfiguration Changes: " )
|
||||
printf '%b\n' "${vimConf[@]}"
|
||||
|
||||
|
||||
popd
|
||||
else
|
||||
printf "\nExiting..\n"
|
||||
fi
|
||||
|
||||
sudo cat /etc/config-vim/configs/.vimrc-README
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue