Commits

Woojong Koh  committed 948e025

Create bin and .vim/tmp directories, and import update_tags.py

  • Participants
  • Parent commits 2a81e29

Comments (0)

Files changed (8)

+--exclude=.hg
+--exclude=.git
+--exclude=.svn
+--exclude=.ropeproject
+--exclude=build
+--exclude=dist

File .vim/tmp/backup/.placeholder

Empty file added.

File .vim/tmp/undo/.placeholder

Empty file added.
 "set nowrapscan		" Do not wrap around
 set history=1000
 set viminfo+=%3		" Save and restore the buffer list
-set undofile
-set noswapfile
 set clipboard=unnamed
 if has('unnamedplus')
     set clipboard=unnamedplus
 set path+=/usr/local/include,/opt/local/include,./include;,./lib;
 set tags+=./tags;
 
+set backup
+set undofile
+set backupdir=~/.vim/tmp/backup
+set undodir=~/.vim/tmp/undo
+set noswapfile
+
 runtime macros/matchit.vim	" Enable matchit
 
 " Mapping
 autocmd BufEnter *.tex silent! setlocal textwidth=75 spell spelllang=en_us
 autocmd BufReadPre,BufNewFile SConstruct,Sconscript set filetype=python
 autocmd BufEnter * if filereadable('SConstruct') || filereadable('SConscript') | silent! setlocal makeprg=scons\ -u | else | silent! setlocal makeprg= | endif
-autocmd BufWritePost,FileWritePost * silent! call UpdateTags()
+autocmd BufWritePost,FileWritePost * call UpdateTags()
 
 function UpdateTags()
     let l:ctags_options = "--sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q"
     let l:ctags_excludes = '--exclude="*/typeof/*" --exclude="*/preprocessed/*"'
 
-    execute "!(cd ". expand("%:p:h") . ";ctags ". l:ctags_options ." *)&"
+    silent! execute "!(cd ". expand("%:p:h") .";ctags ". l:ctags_options ." *)&"
 
     let l:tags_list = findfile("tags", ".;", -1)
     if len(l:tags_list) > 1
         let l:tmpfile = tempname()
         let l:globaltags_path = fnamemodify(l:tags_list[-1], ":p:h")
-        execute "!(cd ". l:globaltags_path .";ctags ". l:ctags_options ." ". l:ctags_excludes ." -f ". l:tmpfile ." --file-scope=no -R; mv ". l:tmpfile ." tags)&"
+
+        if l:globaltags_path == $HOME
+            if len(l:tags_list) > 2
+                let l:globaltags_path = fnamemodify(l:tags_list[-2], ":p:h")
+            else
+                return
+            endif
+        endif
+
+        silent! execute "!(cd ". l:globaltags_path .";ctags ". l:ctags_options ." ". l:ctags_excludes ." -f ". l:tmpfile ." --file-scope=no -R; mv ". l:tmpfile ." tags)&"
     endif
 endfunction
 
-path=(/opt/local/bin /opt/local/sbin /Applications/kdiff3.app/Contents/MacOS/ /opt/local/libexec/perl5.12/sitebin/ $path)
+typeset -U path
+
+path=($HOME/bin /opt/local/bin /opt/local/sbin $path /Applications/kdiff3.app/Contents/MacOS/ /opt/local/libexec/perl5.12/sitebin/)

File bin/bootstrap_mac.sh

+#!/bin/sh
+
+xcodebuild -license
+sudo xcodebuild -license
+
+# Back to My Mac (SSH)
+HOSTNAME=`hostname -s`
+HOSTNAME_CLEANED=${HOSTNAME//-/_}
+EXPORT_STMT="export $HOSTNAME_CLEANED=$HOSTNAME.`echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p'`"
+HOSTNAMES_FILE="$HOME/Dropbox/Mac Sync/.hostnames"
+
+if ! grep "$EXPORT_STMT" "$HOSTNAMES_FILE" > /dev/null; then
+    echo $EXPORT_STMT >> $HOSTNAMES_FILE
+fi
+
+# Update MacPorts
+sudo port selfupdate
+sudo port upgrade outdated
+
+# Install compilers and utilities
+sudo port install autojump
+sudo port install ccache
+sudo port install ctags
+sudo port install gcc47
+sudo port install tig
+sudo port install weechat +aspell +perl +python +tls
+sudo port install wget
+sudo cpan App::Ack
+
+# tmux
+sudo port install tmux
+git clone https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git
+cd tmux-MacOSX-pasteboard
+make reattach-to-user-namespace && sudo cp reattach-to-user-namespace /opt/local/bin
+cd ..
+rm -rf tmux-MacOSX-pasteboard
+
+# Install libraries
+sudo port install glew
+#sudo port install jpeg
+#sudo port install freetype
+
+# Install MacVim

File bin/update_tags.py

+#!/usr/bin/python
+
+"""update_tags.py"""
+
+import os
+import subprocess
+
+__author__ = "Woojong Koh"
+__status__ = "Development"
+
+ctags_options = ['--sort=foldcase', '--c++-kinds=+p', '--fields=+iaS', '--extra=+q']
+ctags_excludes = ['*/typeof/*', '*/preprocessed/*']
+ignores = ['.hg', '.git', '.svn']
+
+if __name__ == "__main__":
+    processes = set()
+    max_processes = 100
+
+    for root, dirs, files in os.walk('.'):
+        dirs[:] = [d for d in dirs if d not in ignores]
+        if len(files) > 0:
+            processes.add(subprocess.Popen(['ctags'] + ctags_options + files, cwd=root))
+            if len(processes) >= max_processes:
+                os.wait()
+                processes.difference_update([p for p in processes if p.poll() is not None])
+
+    # Check if all the child processes were close
+    for p in processes:
+        if p.poll() is None:
+            p.wait()
+
+    p = subprocess.Popen(['ctags'] + ctags_options + ['--exclude=' + x for x in ctags_excludes] + ["--file-scope=no", '-R'])
+    p.wait()

File bootstrap_mac.sh

-#!/bin/sh
-
-xcodebuild -license
-sudo xcodebuild -license
-
-# Back to My Mac (SSH)
-HOSTNAME=`hostname -s`
-HOSTNAME_CLEANED=${HOSTNAME//-/_}
-EXPORT_STMT="export $HOSTNAME_CLEANED=$HOSTNAME.`echo show Setup:/Network/BackToMyMac | scutil | sed -n 's/.* : *\(.*\).$/\1/p'`"
-HOSTNAMES_FILE="$HOME/Dropbox/Mac Sync/.hostnames"
-
-if ! grep "$EXPORT_STMT" "$HOSTNAMES_FILE" > /dev/null; then
-    echo $EXPORT_STMT >> $HOSTNAMES_FILE
-fi
-
-# Update MacPorts
-sudo port selfupdate
-sudo port upgrade outdated
-
-# Install compilers and utilities
-sudo port install autojump
-sudo port install ccache
-sudo port install ctags
-sudo port install gcc47
-sudo port install tig
-sudo port install weechat +aspell +perl +python +tls
-sudo port install wget
-sudo cpan App::Ack
-
-# tmux
-sudo port install tmux
-git clone https://github.com/ChrisJohnsen/tmux-MacOSX-pasteboard.git
-cd tmux-MacOSX-pasteboard
-make reattach-to-user-namespace && sudo cp reattach-to-user-namespace /opt/local/bin
-cd ..
-rm -rf tmux-MacOSX-pasteboard
-
-# Install libraries
-sudo port install glew
-#sudo port install jpeg
-#sudo port install freetype
-
-# Install MacVim