From 4e5f3f8846b400a0b9458e6aff4b862b927a657a Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 1 Aug 2016 15:30:21 -0400 Subject: [PATCH 1/7] Adds files to make vim USB-portable --- usbify/.DS_Store | Bin 0 -> 6148 bytes usbify/README.md | 11 +++ usbify/vim/.DS_Store | Bin 0 -> 6148 bytes usbify/vim/.vim/.DS_Store | Bin 0 -> 6148 bytes usbify/vim/.vim/.netrwhist | 11 +++ usbify/vim/.vim/.vim | 1 + usbify/vim/.vim/bundle/L9 | 1 + usbify/vim/.vim/bundle/Vundle.vim | 1 + usbify/vim/.vim/bundle/command-t | 1 + usbify/vim/.vim/bundle/ctrlp.vim | 1 + usbify/vim/.vim/bundle/nerdtree | 1 + usbify/vim/.vim/bundle/newL9 | 1 + usbify/vim/.vim/bundle/sparkup | 1 + usbify/vim/.vim/bundle/syntastic | 1 + usbify/vim/.vim/bundle/vim-fugitive | 1 + usbify/vim/.vim/bundle/vim-monokai | 1 + usbify/vim/.vim/bundle/yajs.vim | 1 + usbify/vim/.vim/ftdetect/soy.vim | 1 + usbify/vim/.vim/gjslint.vim | 46 +++++++++ usbify/vim/.vim/syntax/soy.vim | 145 ++++++++++++++++++++++++++++ usbify/vim/.vimrc | 89 +++++++++++++++++ usbify/vim/vim_point_to_usb.sh | 36 +++++++ 22 files changed, 351 insertions(+) create mode 100644 usbify/.DS_Store create mode 100644 usbify/README.md create mode 100644 usbify/vim/.DS_Store create mode 100644 usbify/vim/.vim/.DS_Store create mode 100644 usbify/vim/.vim/.netrwhist create mode 120000 usbify/vim/.vim/.vim create mode 160000 usbify/vim/.vim/bundle/L9 create mode 160000 usbify/vim/.vim/bundle/Vundle.vim create mode 160000 usbify/vim/.vim/bundle/command-t create mode 160000 usbify/vim/.vim/bundle/ctrlp.vim create mode 160000 usbify/vim/.vim/bundle/nerdtree create mode 160000 usbify/vim/.vim/bundle/newL9 create mode 160000 usbify/vim/.vim/bundle/sparkup create mode 160000 usbify/vim/.vim/bundle/syntastic create mode 160000 usbify/vim/.vim/bundle/vim-fugitive create mode 160000 usbify/vim/.vim/bundle/vim-monokai create mode 160000 usbify/vim/.vim/bundle/yajs.vim create mode 100644 usbify/vim/.vim/ftdetect/soy.vim create mode 100644 usbify/vim/.vim/gjslint.vim create mode 100644 usbify/vim/.vim/syntax/soy.vim create mode 100644 usbify/vim/.vimrc create mode 100755 usbify/vim/vim_point_to_usb.sh diff --git a/usbify/.DS_Store b/usbify/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..10ebd8500a1c85fea4ffd27109f1d75ea554ec71 GIT binary patch literal 6148 zcmeHKL2KJE6qb@~v+ELkXra&*bYBix7nUAP+Fr(>0hjc!j?Bhl5qNU3orDqsK8*c= z{fzy9{eX>j`wKg7?ceBol2Tf-UAHjw;OTpMdhf~pWF(6aLVM%nDIq=~!~sRDxzPMZ za2$0>YQ}>|u|{zgr&$c0?f7gd+B#N|0bIK}nGiwV#nZd%mx`inw|~%Dz474TBgb9y z*1e|ZuQ$Es>u{7!!!jzzMK8*S{^L+2JdW}ck(8rjE)P>a;qoYd8I?SLg~7*JmO_BG zqj(_rbm(vFXR?fh18CN3~o zY1HY2s+pmVnVFg!3RSa%pQ&&{1C6$|3|I#4Gf>xEAJ6~8Ki~iFC)u85z%uY(F+dv! z;Xw~x$(*fAFNbF>1APOEf^n6`+Y~U=Q4Fzo6mNkl0Y5_nFfdqY1P_S)5l}SP#xn3% G8Mpz;NN?8w literal 0 HcmV?d00001 diff --git a/usbify/README.md b/usbify/README.md new file mode 100644 index 000000000..4486c5984 --- /dev/null +++ b/usbify/README.md @@ -0,0 +1,11 @@ +# USBify + +This folder contains packages to make applications into USB portable. + +## vim +Run the `vim_to_usb.sh` script to point your $HOME/.vim folder to an external USB + +* vim_to_usb.sh +* .vimrc +* .vim + diff --git a/usbify/vim/.DS_Store b/usbify/vim/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d30ee202084538124bbb4acc623c6fa172887fd7 GIT binary patch literal 6148 zcmeHK%}(Pm5VlJfQs5A@i$L0ouSgXtzrAL=a73z{}PN1c*_ z@gQ>S!ylv_KT3S4|C@>?$7^H&*RIIcS)WOEa)15&P9)Q;Qn}-Wnc|1pIjb~3zX*@L zw0PvUlYyIgSud@5-5;tZgU~m2-OJiz`&*Jk6Wj9}G90w*PhXQb^JE-$@1-6#WgH}f zTGESy^w8D)HD!>sTlR9j8}=c!?!{q4rqY*@%zl+h7CbF`WjNg4DT~d`>ZmM+)oP_I zwzqaiBm2~{KCkV3Ir!cg{XRRtxV*al^Y=zC0*CKa$wz}@xCLXvN8jznQ4;?I-#C68 zM@S411H`~vX29%e*1}t!1id>kKny$!1Gqm3P(;UIu2F3rP~h()wigjmz{a}-qA=(f z%r!y_2-m5AI+dF%2G{A}7beazm}}JOjH{8MA2TvHHx#Z$2ft9^j5`{sBnF6qhYZZ< zs*UIW{?qsWhe=c;28e-o#Q-nvxqCI3k~v$aCWmLO06hjp!MI%GBn1q06hkZ?#jBu7 Zz%S4MbPVPi!2?1+0*VGIh=CVn;6E4;V@Ci0 literal 0 HcmV?d00001 diff --git a/usbify/vim/.vim/.DS_Store b/usbify/vim/.vim/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 +"License: This program is free software. It comes without any warranty, +" to the extent permitted by applicable law. You can redistribute +" it and/or modify it under the terms of the Do What The Fuck You +" Want To Public License, Version 2, as published by Sam Hocevar. +" See http://sam.zoy.org/wtfpl/COPYING for more details. +"============================================================================ + +if exists('g:loaded_syntastic_javascript_gjslint_checker') + finish +endif +let g:loaded_syntastic_javascript_gjslint_checker = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! SyntaxCheckers_javascript_gjslint_GetLocList() dict + call syntastic#log#deprecationWarn('javascript_gjslint_conf', 'javascript_gjslint_args') + + let makeprg = self.makeprgBuild({ + \ 'args': '--nodebug_indentation', + \ 'args_after': '--check_html --nosummary --unix_mode --nobeep' }) + + let errorformat = + \ "%f:%l:(New Error -%\\?\%n) %m," . + \ "%f:%l:(-%\\?%n) %m," . + \ "%-G1 files checked," . + \ " no errors found.," . + \ "%-G%.%#" + + return SyntasticMake({ + \ 'makeprg': makeprg, + \ 'errorformat': errorformat }) +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'javascript', + \ 'name': 'gjslint'}) + +let &cpo = s:save_cpo +unlet s:save_cpo + +" vim: set sw=4 sts=4 et fdm=marker: diff --git a/usbify/vim/.vim/syntax/soy.vim b/usbify/vim/.vim/syntax/soy.vim new file mode 100644 index 000000000..8b25b622b --- /dev/null +++ b/usbify/vim/.vim/syntax/soy.vim @@ -0,0 +1,145 @@ +" Google Closure templates syntax file. +" Language: Soy +" Maintainer: Dugan Chen (https://github.com/duganchen) +" +if exists("b:current_syntax") + finish +endif + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syntax clear +syntax case match + +syntax keyword soyConstant contained null +syntax keyword soyConstant contained false +syntax keyword soyConstant contained true + +syntax keyword soyFunction contained isFirst +syntax keyword soyFunction contained isLast +syntax keyword soyFunction contained index +syntax keyword soyFunction contained hasData +syntax keyword soyFunction contained length +syntax keyword soyFunction contained round +syntax keyword soyFunction contained floor +syntax keyword soyFunction contained ceiling +syntax keyword soyFunction contained min +syntax keyword soyFunction contained max +syntax keyword soyFunction contained randomInt +syntax keyword soyFunction contained bidiGlobalDir +syntax keyword soyFunction contained bidiDirAttr +syntax keyword soyFunction contained bidiMark +syntax keyword soyFunction contained bidiMarkAfter +syntax keyword soyFunction contained bidiStartEdge +syntax keyword soyFunction contained bidiEndEdge +syntax keyword soyFunction contained bidiTextDir + +syntax keyword soyStatement contained namespace +syntax keyword soyStatement contained template +syntax keyword soyStatement contained delpackage +syntax keyword soyStatement contained deltemplate + +syntax keyword soyKeyword contained literal +syntax keyword soyKeyword contained print +syntax keyword soyKeyword contained msg +syntax keyword soyKeyword contained call +syntax keyword soyKeyword contained delcall +syntax keyword soyKeyword contained param +syntax keyword soyKeyword contained let +syntax keyword soyKeyword contained css + +syntax keyword soyConditional contained if +syntax keyword soyConditional contained elseif +syntax keyword soyConditional contained else +syntax keyword soyConditional contained switch +syntax keyword soyConditional contained case +syntax keyword soyConditional contained default +syntax keyword soyConditional contained ifempty + +syntax keyword soyRepeat contained foreach +syntax keyword soyRepeat contained for +syntax keyword soyRepeat contained in +syntax keyword soyRepeat contained range + +syntax keyword soyCharacter contained sp +syntax keyword soyCharacter contained nil +syntax keyword soyCharacter contained r +syntax keyword soyCharacter contained n +syntax keyword soyCharacter contained t +syntax keyword soyCharacter contained lb +syntax keyword soyCharacter contained rb + +syntax keyword soyDirective contained private +syntax keyword soyDirective contained autoescape +syntax keyword soyDirective contained noAutoescape +syntax keyword soyDirective contained id +syntax keyword soyDirective contained escapeCssString +syntax keyword soyDirective contained escapeHtml +syntax keyword soyDirective contained escapeHtmlRcdata +syntax keyword soyDirective contained escapeHtmlAttribute +syntax keyword soyDirective contained escapeHtmlAttributeNospace +syntax keyword soyDirective contained escapeUri +syntax keyword soyDirective contained escapeJs +syntax keyword soyDirective contained escapeJsRegex +syntax keyword soyDirective contained escapeJsString +syntax keyword soyDirective contained escapeJsValue +syntax keyword soyDirective contained truncate +syntax keyword soyDirective contained insertWordBreaks +syntax keyword soyDirective contained changeNewlineToBr +syntax keyword soyDirective contained desc +syntax keyword soyDirective contained meaning +syntax keyword soyDirective contained data +syntax keyword soyDirective contained kind +syntax keyword soyDirective contained variant +syntax keyword soyDirective contained bidiSpanWrap +syntax keyword soyDirective contained bidiUnicodeWrap + +syntax match soySpecialComment /@param?\?/ contained + +syntax region soyCommand start="{" end="}" contains=soyKeyword, soyDirective, soyIdentifier, soyString, soyTemplate, soyConstant, soyInteger, soyCharacter, soyFloat, soySci, soyOperator, soyFunction, soyRepeat, soyConditional, soyStatement, soyLabel + +syntax region soyString contained start="\'" end="\'" +syntax region soyString contained start="\"" end="\"" + +syntax match soyIdentifier /\$[a-zA-Z0-9._]*\>/ contained +syntax region soyComment start=/\/\*/ end='\\*\/' contains=soySpecialComment + +syntax match soyComment /\/\/.*$/ +syntax match soyTemplate /\s\+\.\w\+\>/ contained + +syntax match soyInteger /\-\?\(0x\)\?[A-F0-9]\+\>/ contained + +syntax match soyNumber /\-\?\d\+\(e\-\?\d\+\)\?\>/ contained + +syntax match soyFloat /\-\?\d\+\.\d\+\>/ contained +syntax match soySci /\-\?\d\+e\-\?\d\+\>/ contained + +syntax match soyOperator /\<\(not\|and\|or\)\>/ contained + +syntax match soyLabel /\<\w\+:/ contained + +" Yes, this causes the - in -1 to show as an operator. This is a bug. +syntax match soyOperator /[-*/%+<>=!?:]/ contained + +highlight def link soyOperator Operator +highlight def link soyKeyword Statement +highlight def link soyDirective Type +highlight def link soyIdentifier Identifier +highlight def link soyString String +highlight def link soyComment Comment +highlight def link soyTemplate Identifier +highlight def link soyInteger Number +highlight def link soyFloat Float +highlight def link soySci Float +highlight def link soyConstant Constant +highlight def link soyCharacter Character +highlight def link soyFunction Function +highlight def link soyRepeat Repeat +highlight def link soyConditional Conditional +highlight def link soyStatement Statement +highlight def link soySpecialComment SpecialComment +highlight def link soyLabel Identifier diff --git a/usbify/vim/.vimrc b/usbify/vim/.vimrc new file mode 100644 index 000000000..dd720b76b --- /dev/null +++ b/usbify/vim/.vimrc @@ -0,0 +1,89 @@ +" -- BEGIN: Vundle config -- +set nocompatible " be iMproved, required +filetype off " required + +" set the runtime path to include Vundle and initialize +set rtp+=~/.vim/bundle/Vundle.vim +call vundle#begin() +" alternatively, pass a path where Vundle should install plugins +"call vundle#begin('~/some/path/here') + +" let Vundle manage Vundle, required +Plugin 'VundleVim/Vundle.vim' + +" The following are examples of different formats supported. +" Keep Plugin commands between vundle#begin/end. +" plugin on GitHub repo +Plugin 'tpope/vim-fugitive' + +" All of your Plugins must be added before the following line +Plugin 'othree/yajs.vim' +Plugin 'crusoexia/vim-monokai' +Plugin 'scrooloose/syntastic' +Plugin 'scrooloose/nerdtree' + +call vundle#end() " required +filetype plugin indent on " required +" To ignore plugin indent changes, instead use: +"filetype plugin on +" +" Brief help +" :PluginList - lists configured plugins +" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate +" :PluginSearch foo - searches for foo; append `!` to refresh local cache +" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal +" +" see :h vundle for more details or wiki for FAQ +" Put your non-Plugin stuff after this line +" -- END: Vundle config -- + + +" -- Syntastic Settings -- +set statusline+=%#warningmsg# +set statusline+=%{SyntasticStatuslineFlag()} +set statusline+=%* + +let g:syntastic_always_populate_loc_list = 1 +let g:syntastic_auto_loc_list = 1 +let g:syntastic_check_on_open = 1 +let g:syntastic_check_on_wq = 1 +let g:syntastic_javascript_checkers = ['gjslint'] + + +syntax on +set number +set tabstop=2 +set expandtab +set shiftwidth=2 +colorscheme monokai +set t_Co=255 + + +" add 80 character wrap line +highlight OverLength ctermbg=red ctermfg=white guibg=#592929 +match OverLength /\%81v.\+/ + + +" map jj to +imap jj + +" map ctrl + n to :NERDTree +map :NERDTreeToggle + + + +" trim trailing whitespace on save +autocmd BufWritePre *.{js,py,tpl,html} :%s/\s\+$//e + +" set default font and size +set guifont=Operator\ Mono:h16 + + +" -- fuzzy-finder -- +set runtimepath^=~/.vim/bundle/ctrlp.vim +let g:ctrlp_map = '' +let g:ctrlp_cmd = 'CtrlP' +let g:ctrlp_custom_ignore = { + \ 'dir': 'node_modules' + \ } + diff --git a/usbify/vim/vim_point_to_usb.sh b/usbify/vim/vim_point_to_usb.sh new file mode 100755 index 000000000..db86e93a4 --- /dev/null +++ b/usbify/vim/vim_point_to_usb.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# This script points the .vim directory to a USB to increase portability +# it will toggle between modes + +if [ -L "$HOME/.vim" ]; then + echo "Already pointing to USB. Toggling back..." + + # remove the symlink and .vimrc + rm "$HOME/.vim" + + # remove the USB's version of the .vimrc and use the backed-up copy + rm "$HOME/.vimrc" + mv "$HOME/.vimrc.bak" "$HOME/.vimrc" + + # rename the .vim.bak directory + mv "$HOME/.vim.bak" "$HOME/.vim" + + echo ".vim now points to $HOME/.vim" +else + echo "Not pointing to USB. Getting to work..." + + # rename the current .vim directory and .vimrc + mv "$HOME/.vim" "$HOME/.vim.bak" + mv "$HOME/.vimrc" "$HOME/.vimrc.bak" + + # point the $HOME/.vim name to the USB for source routing + # use the USB drive's copy of .vimrc + ln -s /Volumes/Untitled\ 1/.vim "$HOME/.vim" + cp /Volumes/Untitled\ 1/.vimrc "$HOME/" + + echo ".vim now points to /Volumes/Untitled\ 1/.vim" +fi + +echo "Done." + From 2021514c9c6a212462b9a58e3ec6cd5b1d4cff3b Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 1 Aug 2016 15:36:36 -0400 Subject: [PATCH 2/7] Updates copy in vim script --- usbify/vim/vim_point_to_usb.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/usbify/vim/vim_point_to_usb.sh b/usbify/vim/vim_point_to_usb.sh index db86e93a4..00c428930 100755 --- a/usbify/vim/vim_point_to_usb.sh +++ b/usbify/vim/vim_point_to_usb.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash -# This script points the .vim directory to a USB to increase portability -# it will toggle between modes +# This script toggles between local vim and a version that can be stored on an +# external device like a USB. if [ -L "$HOME/.vim" ]; then - echo "Already pointing to USB. Toggling back..." + echo "Pointing to USB. Toggling back to local machine..." # remove the symlink and .vimrc rm "$HOME/.vim" @@ -18,7 +18,7 @@ if [ -L "$HOME/.vim" ]; then echo ".vim now points to $HOME/.vim" else - echo "Not pointing to USB. Getting to work..." + echo "Pointing to local machine. Toggling to USB..." # rename the current .vim directory and .vimrc mv "$HOME/.vim" "$HOME/.vim.bak" From 243cb92da9e8a0f46cbe1bd36ad4ea14037ab57a Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 1 Aug 2016 15:46:24 -0400 Subject: [PATCH 3/7] Updates script to use symlink instead of file copy --- usbify/vim/vim_point_to_usb.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usbify/vim/vim_point_to_usb.sh b/usbify/vim/vim_point_to_usb.sh index 00c428930..e2faa9d9b 100755 --- a/usbify/vim/vim_point_to_usb.sh +++ b/usbify/vim/vim_point_to_usb.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash +path_to_ext_device="/Volumes/usb_vim" + # This script toggles between local vim and a version that can be stored on an # external device like a USB. @@ -26,10 +28,10 @@ else # point the $HOME/.vim name to the USB for source routing # use the USB drive's copy of .vimrc - ln -s /Volumes/Untitled\ 1/.vim "$HOME/.vim" - cp /Volumes/Untitled\ 1/.vimrc "$HOME/" + ln -s "${path_to_ext_device}/.vim" "$HOME/.vim" + ln -s "${path_to_ext_device}/.vimrc" "$HOME/.vimrc" - echo ".vim now points to /Volumes/Untitled\ 1/.vim" + echo ".vim now points to ${path_to_ext_device}/.vim" fi echo "Done." From ace1147a82864a6a27c710af5cbccd9f1b319f20 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 1 Aug 2016 16:02:14 -0400 Subject: [PATCH 4/7] Adds null checks to script --- usbify/vim/.DS_Store | Bin 6148 -> 0 bytes usbify/vim/vim_point_to_usb.sh | 9 +++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) delete mode 100644 usbify/vim/.DS_Store diff --git a/usbify/vim/.DS_Store b/usbify/vim/.DS_Store deleted file mode 100644 index d30ee202084538124bbb4acc623c6fa172887fd7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHK%}(Pm5VlJfQs5A@i$L0ouSgXtzrAL=a73z{}PN1c*_ z@gQ>S!ylv_KT3S4|C@>?$7^H&*RIIcS)WOEa)15&P9)Q;Qn}-Wnc|1pIjb~3zX*@L zw0PvUlYyIgSud@5-5;tZgU~m2-OJiz`&*Jk6Wj9}G90w*PhXQb^JE-$@1-6#WgH}f zTGESy^w8D)HD!>sTlR9j8}=c!?!{q4rqY*@%zl+h7CbF`WjNg4DT~d`>ZmM+)oP_I zwzqaiBm2~{KCkV3Ir!cg{XRRtxV*al^Y=zC0*CKa$wz}@xCLXvN8jznQ4;?I-#C68 zM@S411H`~vX29%e*1}t!1id>kKny$!1Gqm3P(;UIu2F3rP~h()wigjmz{a}-qA=(f z%r!y_2-m5AI+dF%2G{A}7beazm}}JOjH{8MA2TvHHx#Z$2ft9^j5`{sBnF6qhYZZ< zs*UIW{?qsWhe=c;28e-o#Q-nvxqCI3k~v$aCWmLO06hjp!MI%GBn1q06hkZ?#jBu7 Zz%S4MbPVPi!2?1+0*VGIh=CVn;6E4;V@Ci0 diff --git a/usbify/vim/vim_point_to_usb.sh b/usbify/vim/vim_point_to_usb.sh index e2faa9d9b..98369170f 100755 --- a/usbify/vim/vim_point_to_usb.sh +++ b/usbify/vim/vim_point_to_usb.sh @@ -22,9 +22,14 @@ if [ -L "$HOME/.vim" ]; then else echo "Pointing to local machine. Toggling to USB..." - # rename the current .vim directory and .vimrc + # back-up local machine's .vim folder mv "$HOME/.vim" "$HOME/.vim.bak" - mv "$HOME/.vimrc" "$HOME/.vimrc.bak" + + # back-up the local machine's .vimrc + if [ -f "HOME/.vimrc" ]; then + mv "$HOME/.vimrc" "$HOME/.vimrc.bak" + fi + # point the $HOME/.vim name to the USB for source routing # use the USB drive's copy of .vimrc From 0da48c129097c871bd6c74778df1383dca68a4ab Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 1 Aug 2016 16:33:08 -0400 Subject: [PATCH 5/7] Updates scripts to be more defensive --- usbify/vim/.vim/.vim | 1 - 1 file changed, 1 deletion(-) delete mode 120000 usbify/vim/.vim/.vim diff --git a/usbify/vim/.vim/.vim b/usbify/vim/.vim/.vim deleted file mode 120000 index 500cab06d..000000000 --- a/usbify/vim/.vim/.vim +++ /dev/null @@ -1 +0,0 @@ -/Users/wcarroll/.vim \ No newline at end of file From 4014e4ac7e1e112d644267ca27c77220e6c43aca Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 1 Aug 2016 17:00:06 -0400 Subject: [PATCH 6/7] Adds protection to script --- usbify/vim/vim_point_to_usb.sh | 49 ++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/usbify/vim/vim_point_to_usb.sh b/usbify/vim/vim_point_to_usb.sh index 98369170f..7ea24fb0b 100755 --- a/usbify/vim/vim_point_to_usb.sh +++ b/usbify/vim/vim_point_to_usb.sh @@ -2,41 +2,50 @@ path_to_ext_device="/Volumes/usb_vim" + +# ensure there is an external device connected and that the path to it is +# accurate. +if [ ! -d "$path_to_ext_device" ]; then + echo "No external device found at: $path_to_ext_device" + echo "Ensure that the value set for path_to_ext_device is correct." + echo "path_to_ext_device: $path_to_ext_device" + echo "Exiting." + return 1 +fi + + + # This script toggles between local vim and a version that can be stored on an # external device like a USB. -if [ -L "$HOME/.vim" ]; then +# USB --> local machine +if [ -L "$HOME/.vim" ] && [ -L "$HOME/.vimrc" ]; then echo "Pointing to USB. Toggling back to local machine..." - # remove the symlink and .vimrc + # remove the symlinks rm "$HOME/.vim" - - # remove the USB's version of the .vimrc and use the backed-up copy rm "$HOME/.vimrc" - mv "$HOME/.vimrc.bak" "$HOME/.vimrc" - # rename the .vim.bak directory - mv "$HOME/.vim.bak" "$HOME/.vim" + # restore back-ups as active files + [ -d "$HOME/.vim.bak" ] && mv "$HOME/.vim.bak" "$HOME/.vim" + [ -f "$HOME/.vimrc.bak" ] && mv "$HOME/.vimrc.bak" "$HOME/.vimrc" echo ".vim now points to $HOME/.vim" + echo ".vimrc now points to $HOME/.vimrc" + +# local machine --> USB else echo "Pointing to local machine. Toggling to USB..." - # back-up local machine's .vim folder - mv "$HOME/.vim" "$HOME/.vim.bak" + # back-up local machine's files + [ -d "$HOME/.vim" ] && mv "$HOME/.vim" "$HOME/.vim.bak" + [ -f "$HOME/.vimrc" ] && mv "$HOME/.vimrc" "$HOME/.vimrc.bak" - # back-up the local machine's .vimrc - if [ -f "HOME/.vimrc" ]; then - mv "$HOME/.vimrc" "$HOME/.vimrc.bak" - fi + # symlink .vim and .vimrc to external device + ln -s "${path_to_ext_device}/vim/.vim" "$HOME/.vim" + ln -s "${path_to_ext_device}/vim/.vimrc" "$HOME/.vimrc" - - # point the $HOME/.vim name to the USB for source routing - # use the USB drive's copy of .vimrc - ln -s "${path_to_ext_device}/.vim" "$HOME/.vim" - ln -s "${path_to_ext_device}/.vimrc" "$HOME/.vimrc" - - echo ".vim now points to ${path_to_ext_device}/.vim" + echo ".vim now points to ${path_to_ext_device}/vim/.vim" fi echo "Done." From 0e15b28b672312f8c3b70f77295b56facf19a27d Mon Sep 17 00:00:00 2001 From: William Carroll Date: Mon, 1 Aug 2016 17:05:09 -0400 Subject: [PATCH 7/7] Adds update script to run on USB device to sync with github repo --- usbify/update.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 usbify/update.sh diff --git a/usbify/update.sh b/usbify/update.sh new file mode 100755 index 000000000..b17e1d0d0 --- /dev/null +++ b/usbify/update.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# This script is used to ensure the USB has the latest code from the repository. + +# Update the following values to reflect the locations of each directory on your +# particular machine. +path_to_local_repo="$HOME/pc_settings" # path to git repo +path_to_ext_device="/Volumes/usb_vim/" # path to USB device + +if [ ! -d "$path_to_ext_device" ]; then + echo "No external device found at ${path_to_ext_device}." + echo "Make sure the values input within update.sh are correct." + echo "path_to_ext_device: $path_to_ext_device" + echo "Exiting." + return 1 +fi + +if [ ! -d "$path_to_local_repo" ]; then + echo "No repository found at ${path_to_local_repo}." + echo "Make sure the values input within update.sh are correct." + echo "path_to_local_repo: $path_to_local_repo" + echo "Exiting." + return 1 +fi + +pushd "$path_to_ext_device" >/dev/null + +# Update the local copy of the repo. +echo "Updating pc_settings..." +pushd "$path_to_local_repo" >/dev/null +git pull origin master +echo "" + +echo "Copying files to external device..." +popd # $(pwd) -eq $path_to_ext_device +# copy the vim contents from $HOME/pc_settings into $path_to_ext_device +rm -rf ./vim +cp -r "${path_to_local_repo}/usbify/vim" . +echo "" + +popd # restore the dirs to its state before running this script + +echo "Done." +