diff options
author | LAN-TW <lantw44@gmail.com> | 2013-07-28 14:51:36 +0800 |
---|---|---|
committer | LAN-TW <lantw44@gmail.com> | 2013-07-28 14:51:36 +0800 |
commit | c2f14734f7a0696e6db908e877d16458b6bed128 (patch) | |
tree | cf3fe8ea32fa7b9a4c8a79b8fc177e78b4b6300a | |
parent | ddd97930b8ea1cd105ddc1218ceb8237191cc573 (diff) | |
download | configfile-c2f14734f7a0696e6db908e877d16458b6bed128.tar configfile-c2f14734f7a0696e6db908e877d16458b6bed128.tar.gz configfile-c2f14734f7a0696e6db908e877d16458b6bed128.tar.bz2 configfile-c2f14734f7a0696e6db908e877d16458b6bed128.tar.lz configfile-c2f14734f7a0696e6db908e877d16458b6bed128.tar.xz configfile-c2f14734f7a0696e6db908e877d16458b6bed128.tar.zst configfile-c2f14734f7a0696e6db908e877d16458b6bed128.zip |
bash_include: 自動下載設定檔 | vimrc: neocomplete 外掛、GTK+ 語法標記vimrc-20130728bash_include-20130728
-rw-r--r-- | bash_include | 103 | ||||
-rw-r--r-- | vimrc | 25 |
2 files changed, 127 insertions, 1 deletions
diff --git a/bash_include b/bash_include index 36cb8a8..1fc6a6f 100644 --- a/bash_include +++ b/bash_include @@ -922,6 +922,74 @@ function path_editor () ########## New PATH Editor End ########## +########## Configuration File ########## + +function configfile_fetch () +{ + local mirror_list=" + http://www.tfcis.org/~lantw44/configfile/ + http://phantom.tfcis.org/~lantw44/mirror/forum_tfcis_org/configfile/ + http://master.lant.com.tw/~lantw44/configfile/ + http://www.csie.ntu.edu.tw/~b01902062/configfile/" + local url_append + local file_name + local file_version + + if [ "$3" ]; then + url_append="$3" + else + url_append="Unix-like/" + fi + if [ "$1" ]; then + file_name="$1" + else + file_name="bash_include vimrc screenrc" + fi + if [ "$2" ]; then + file_version="-$2" + else + url_append="${url_append}latest/" + fi + + for file in $file_name + do + for site in $mirror_list + do + if fetch_remote_file "$HOME/.${file}.new" \ + "${site}${url_append}${file}${file_version}" + then + mv -vf "$HOME/.${file}.new" "$HOME/.${file}" + break + fi + done + done +} + +function configfile_initial_setup () +{ + cat >> ~/.bashrc << EOF +if [ -f ~/.bash_include ]; then + . ~/.bash_include +fi +EOF + if [ "`uname`" = "FreeBSD" ]; then + cat >> ~/.bash_login << EOF +GET_TTY_NAME=`tty | cut -c 9` +[ "$GET_TTY_NAME" = 'v' ] && echo "Login from local virtual terminal: `tty`" +[ "$GET_TTY_NAME" = 'p' ] && echo "Login from pseudo terminal: `tty`" +[ "$GET_TTY_NAME" = '/' ] && echo "Login from pseudo terminal: `tty`" +unset GET_TTY_NAME +EOF + fi + cat >> ~/.bash_login << EOF +if [ -f ~/.bash_include ]; then + . ~/.bashrc +fi +EOF +} + +########## Configuration File End ########## + function varset () { local varoldvalue @@ -1176,6 +1244,37 @@ function unzip_nomac () return $? } +function check_command_existent () +{ + which "$1" &> /dev/null + return $? +} + +function fetch_remote_file () +{ + local rval + printf "==> Fetch remote file \e[1;33m$2\e[m as \e[1;35m$1\e[m ...\n" + if check_command_existent curl; then + curl -f -o "$1" "$2" + rval=$? + elif check_command_existent fetch; then + fetch -o "$1" "$2" + rval=$? + elif check_command_existent wget; then + wget --progress=dot -O "$1" "$2" + rval=$? + else + echo "<== Sorry, I don't know how to fetch remote files on your system" + return 1 + fi + if [ "$rval" = "0" ]; then + printf "<== \e[1;32mDone\e[m\n" + else + printf "<== \e[1;31mFailed\e[m\n" + fi + return $rval +} + ########## Help ########## alias helpf='help_function' @@ -1243,6 +1342,10 @@ function help_function () ldpath_editor x newpath_init x newpath_gen + <<< Group: Configuration File >>> + configfile_fetch [file_name_list [file_version [system_type]]] + configfile_initial_setup + x fetch_remote_file local_file_name remote_url <<< Other >>> backup_file filename ... [-- sudo_prefix ...] check_dmesg seconds @@ -5,6 +5,7 @@ let $CFLAGS="-Wall -pipe -g" let $LDFLAGS="" let g:quick_fix_window_on = 0 let g:plugins_enabled = 0 +let g:use_neocomplete = 0 set bs=2 set ls=2 set ts=4 @@ -45,6 +46,13 @@ function! ToggleQuickFixWindow() endif endfunction +function! LoadGtkSyntaxFiles() + for i in ['atk', 'atspi', 'cairo', 'clutter', 'dbusglib', 'evince', 'gdkpixbuf', 'gimp', 'glib', 'gnomedesktop', 'gobjectintrospection', 'gstreamer', 'gtk2', 'gtk3', 'gtkglext', 'gtksourceview', 'jsonglib', 'libgsf', 'libnotify', 'librsvg', 'libsoup', 'libunique', 'libwnck', 'pango', 'poppler', 'vte', 'xlib' ] + execute 'runtime! syntax/' . i . '.vim' + execute 'let ' . i . '_deprecated_errors = 1' + endfor +endfunction + map <F1> :set foldmethod=syntax map <F2> :call ToggleQuickFixWindow()<CR> map <F3> :cp<CR> @@ -90,11 +98,26 @@ if g:plugins_enabled call vundle#rc() Bundle 'gmarik/vundle' Bundle 'Lokaltog/powerline' - Bundle 'Valloric/YouCompleteMe' Bundle 'majutsushi/tagbar' Bundle 'scrooloose/nerdtree' Bundle 'othree/html5.vim' Bundle 'tkztmk/vim-vala' + Bundle 'gtk-vim-syntax' + if g:use_neocomplete + Bundle 'Shougo/neocomplete.vim' + Bundle 'Shougo/vimproc' + Bundle 'Shougo/context_filetype.vim' + let g:neocomplete#enable_at_startup = 1 + let g:neocomplete#enable_auto_select = 1 + let g:neocomplete#enable_insert_char_pre = 1 + let g:neocomplete#enable_fuzzy_completion = 1 + let g:neocomplete#max_list = 10 + let g:neocomplete#data_directory = "~/tmp/neocomplete" + else + Bundle 'Valloric/YouCompleteMe' + endif + au FileType c call LoadGtkSyntaxFiles() + au FileType cpp call LoadGtkSyntaxFiles() endif if has("cscope") |