-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinst-vim-simple.sh
executable file
·120 lines (93 loc) · 4.29 KB
/
inst-vim-simple.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
# shellcheck disable=SC1090,SC1091,SC2059,SC2154,SC2116,SC1117
# FIXME: SC1117
#------------------------------------------------------------------------------
# PURPOSE: A QnD script to configure a base environment so I can get back to
# work quickly. It will be replaced by Ansible automation as soon as
# possible between laptop upgrades.
# PASS 'TEST' as the first argument; if not, it's LIVE.
#------------------------------------------------------------------------------
# EXECUTE: ./bootstrap.sh <TEST> 2>&1 | tee ~/.config/admin/logs/mac-ops-config.out
#------------------------------------------------------------------------------
# PREREQS: 1) ssh keys must be on the new system for Github clones
# 2)
#------------------------------------------------------------------------------
# AUTHOR: todd-dsm
#------------------------------------------------------------------------------
set -x
###------------------------------------------------------------------------------
### VARIABLES
###------------------------------------------------------------------------------
myCode="$HOME/code"
vimSimpleLocal="$myCode/vimsimple"
vimSimpleGitRepo='https://github.com/todd-dsm/vimSimple.git'
pymodConfig="$vimSimpleLocal/vim/bundle/python-mode/plugin/pymode.vim"
vimSimpleTag='" vimSimple configuration'
jsonIndREGEX='" =================$'
jsonAppendStr='autocmd filetype json set et ts=2 sw=2 sts=2'
jsonIndent="$vimSimpleLocal/vim/bundle/vim-json/indent/json.vim"
termDir="${configDir}/term"
### calm the homebrew messages
export HOMEBREW_NO_ENV_HINTS=TRUE
###----------------------------------------------------------------------------
### FUNCTIONS
###----------------------------------------------------------------------------
### source-in the print library
###---
source lib/print-message-formatting.sh
###----------------------------------------------------------------------------
### Configure Vim
###----------------------------------------------------------------------------
printReq "Pulling the vimSimple repo..."
git clone --recursive -j10 "$vimSimpleGitRepo" "$vimSimpleLocal"
###----------------------------------------------------------------------------
### Modify 1-off configurations on current submodules
####---
printHead "Making 1-off configuration changes..."
### python-mode: disable: 'pymode_rope'
printHead "Disabling pymode_rope..."
printInfo "Check Value before change:"
ropeBool="$(grep "('g:pymode_rope', \w)$" "$pymodConfig")"
ropeBool="${ropeBool:(-2):1}"
if [[ "$ropeBool" -ne '0' ]]; then
printInfo "Value is $ropeBool, Changing the value to Zero..."
sed -i "/'g:pymode_rope', 1/ s/1/0/g" "$pymodConfig"
sed -i "/'g:pymode_rope', 0/i $vimSimpleTag" "$pymodConfig"
else
printInfo "Value is already Zero"
grep "('g:pymode_rope', \w)$" "$pymodConfig"
fi
### Print the value for logging
printHead "The pymode_rope plugin is disabled:"
grep "('g:pymode_rope', \w)$" "$pymodConfig"
###---
### json-vim: add: 'autocmd' to the top of the file
###---
sed -i "/$jsonIndREGEX/a $jsonAppendStr" "$jsonIndent"
### json-vim: add a space seperator
sed -i "/$jsonIndREGEX/G" "$jsonIndent"
### json-vim: add: tag as vimSimple configuration
sed -i "/${jsonAppendStr%%\ *}/i $vimSimpleTag" "$jsonIndent"
### Make softlinks to the important files
printHead "Creating softlinks for ~/.vim and ~/.vimrc"
ln -s "$vimSimpleLocal/vimrc" ~/.vimrc
ln -s "$vimSimpleLocal/vim" ~/.vim
ls -dl ~/.vimrc ~/.vim
###----------------------------------------------------------------------------
### Nvim Configurations
###----------------------------------------------------------------------------
printReq "Neovim post-install configurations:"
printHead "Saving default \$TERM details > ~/config/term/..."
mkdir "$termDir"
infocmp "$TERM" > "$termDir/$TERM.ti"
infocmp "$TERM" | sed 's/kbs=^[hH]/kbs=\\177/' > "$termDir/$TERM-nvim.ti"
printHead "Compiling terminfo for Neovim warning..."
tic "$termDir/$TERM-nvim.ti"
printHead "Linking to existing .vim directory..."
ln -s "$vimSimpleLocal/vim" "$nvimDir"
printHead "Linking to existing .vimrc file..."
ln -s "$vimSimpleLocal/vimrc" "$nvimDir/init.vim"
###----------------------------------------------------------------------------
### Fin~
###----------------------------------------------------------------------------
printInfo