Jelajahi Sumber

Add screenshot to readme

Weiyi Lou 9 tahun lalu
induk
melakukan
59b7763f9f
8 mengubah file dengan 51 tambahan dan 26 penghapusan
  1. 3 1
      README.md
  2. 2 2
      bin/dotfiles-upgrade
  3. 0 0
      docs/man/man1/v.1
  4. 2 1
      docs/man/man1/z.1
  5. TEMPAT SAMPAH
      docs/screenshot.png
  6. 13 11
      shell/common/z.sh
  7. 1 1
      shell/env
  8. 30 10
      vim/autoload/plug.vim

+ 3 - 1
README.md

@@ -10,6 +10,8 @@ Configuration files for:
 
 Heavy preference for Vim-like bindings.
 
+![Screenshot](docs/screenshot.png)
+
 ## Installation
 
 Clone to a home folder and run `make install` or `./install`.
@@ -26,7 +28,7 @@ Restart the terminal session.
 - [pandoc-citeproc][] - bibliographical assistance when using Pandoc.
 
 [Solarized]: http://ethanschoonover.com/solarized
-[Meslo for Powerline]: https://github.com/Lokaltog/powerline-fonts
+[Meslo for Powerline]: https://github.com/powerline/fonts
 [Rainbarf]: https://github.com/creaktive/rainbarf
 [Vim-Plug]: https://github.com/junegunn/vim-plug
 [The Silver Searcher]: https://github.com/ggreer/the_silver_searcher

+ 2 - 2
bin/dotfiles-upgrade

@@ -46,13 +46,13 @@ echo "z"
 curl -# https://raw.githubusercontent.com/rupa/z/master/z.sh \
   -o ~/dotfiles/shell/common/z.sh
 curl -# https://raw.githubusercontent.com/rupa/z/master/z.1 \
-  -o ~/dotfiles/shell/man/man1/z.1
+  -o ~/dotfiles/docs/man/man1/z.1
 
 echo "v"
 curl -# https://raw.githubusercontent.com/rupa/v/master/v \
   -o ~/dotfiles/bin/v && chmod 0755 ~/dotfiles/bin/v
 curl -# https://raw.githubusercontent.com/rupa/v/master/v.1 \
-  -o ~/dotfiles/shell/man/man1/v.1
+  -o ~/dotfiles/docs/man/man1/v.1
 
 echo "coloured manpages"
 curl -# https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/plugins/colored-man-pages/colored-man-pages.plugin.zsh \

+ 0 - 0
shell/man/man1/v.1 → docs/man/man1/v.1


+ 2 - 1
shell/man/man1/z.1 → docs/man/man1/z.1

@@ -93,7 +93,8 @@ Set \fB$_Z_OWNER\fR to allow usage when in 'sudo -s' mode.
 (These settings should go in .bashrc/.zshrc before the line added above.)
 .RE
 .RS
-Install the provided man page \fBz.1\fR somewhere like \fB/usr/local/man/man1\fR.
+Install the provided man page \fBz.1\fR somewhere in your \f$MANPATH, like
+\fB/usr/local/man/man1\fR.
 .RE
 .SS
 Aging:

TEMPAT SAMPAH
docs/screenshot.png


+ 13 - 11
shell/common/z.sh

@@ -34,6 +34,14 @@ _z() {
     # bail if we don't own ~/.z and $_Z_OWNER not set
     [ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
 
+    _z_dirs () {
+      while read line; do
+        # only count directories
+        [ -d "${line%%\|*}" ] && echo $line
+      done < "$datafile"
+      return 0
+    }
+
     # add entries
     if [ "$1" = "--add" ]; then
         shift
@@ -49,10 +57,7 @@ _z() {
 
         # maintain the data file
         local tempfile="$datafile.$RANDOM"
-        while read line; do
-            # only count directories
-            [ -d "${line%%\|*}" ] && echo $line
-        done < "$datafile" | awk -v path="$*" -v now="$(date +%s)" -F"|" '
+        awk < <( _z_dirs ) -v path="$*" -v now="$(date +%s)" -F"|" '
             BEGIN {
                 rank[path] = 1
                 time[path] = now
@@ -75,7 +80,7 @@ _z() {
                 } else for( x in rank ) print x "|" rank[x] "|" time[x]
             }
         ' 2>/dev/null >| "$tempfile"
-        # do our best to avoid clobbering the datafile in a race condition
+        # do our best to avoid clobbering the datafile in a race condition.
         if [ $? -ne 0 -a -f "$datafile" ]; then
             env rm -f "$tempfile"
         else
@@ -127,9 +132,7 @@ _z() {
         [ -f "$datafile" ] || return
 
         local cd
-        cd="$(while read line; do
-            [ -d "${line%%\|*}" ] && echo $line
-        done < "$datafile" | awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
+        cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
             function frecent(rank, time) {
                 # relate frequency and time
                 dx = t - time
@@ -198,9 +201,8 @@ _z() {
                 }
             }
         ')"
-        [ $? -gt 0 ] && return
-        [ "$cd" ] || return
-        ${echo:-cd} "$cd"
+
+        [ $? -eq 0 ] && [ "$cd" ] && ${echo:-cd} "$cd"
     fi
 }
 

+ 1 - 1
shell/env

@@ -4,7 +4,7 @@ export PAGER='less'
 
 # Paths
 export PATH=$HOME/dotfiles/bin:$HOME/bin:$PATH
-export MANPATH=$MANPATH:$HOME/dotfiles/shell/man
+export MANPATH=$MANPATH:$HOME/dotfiles/docs/man
 
 # Machine-specific environment settings
 [[ -n ${BASH_VERSION-} && -r ~/.bashenv.local ]] && source ~/.bashenv.local

+ 30 - 10
vim/autoload/plug.vim

@@ -28,6 +28,9 @@
 "   " Using a non-master branch
 "   Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
 "
+"   " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
+"   Plug 'fatih/vim-go', { 'tag': '*' }
+"
 "   " Plugin options
 "   Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
 "
@@ -128,7 +131,7 @@ function! plug#begin(...)
 endfunction
 
 function! s:define_commands()
-  command! -nargs=+ -bar Plug call s:Plug(<args>)
+  command! -nargs=+ -bar Plug call plug#(<args>)
   if !executable('git')
     return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.')
   endif
@@ -222,7 +225,9 @@ function! plug#end()
     if has_key(plug, 'for')
       let types = s:to_a(plug.for)
       if !empty(types)
+        augroup filetypedetect
         call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim')
+        augroup END
       endif
       for type in types
         call s:assoc(lod.ft, type, name)
@@ -484,7 +489,7 @@ function! s:lod_map(map, names, prefix)
   call feedkeys(a:prefix . substitute(a:map, '^<Plug>', "\<Plug>", '') . extra)
 endfunction
 
-function! s:Plug(repo, ...)
+function! plug#(repo, ...)
   if a:0 > 1
     return s:err('Invalid number of arguments (1..2)')
   endif
@@ -717,15 +722,25 @@ function! s:assign_name()
   silent! execute 'f' fnameescape(name)
 endfunction
 
+function! s:chsh(swap)
+  let prev = [&shell, &shellredir]
+  if !s:is_win && a:swap
+    set shell=sh shellredir=>%s\ 2>&1
+  endif
+  return prev
+endfunction
+
 function! s:bang(cmd, ...)
   try
+    let [sh, shrd] = s:chsh(a:0)
     " FIXME: Escaping is incomplete. We could use shellescape with eval,
     "        but it won't work on Windows.
-    let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
+    let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd
     let g:_plug_bang = '!'.escape(cmd, '#!%')
     execute "normal! :execute g:_plug_bang\<cr>\<cr>"
   finally
     unlet g:_plug_bang
+    let [&shell, &shellredir] = [sh, shrd]
   endtry
   return v:shell_error ? 'Exit status: ' . v:shell_error : ''
 endfunction
@@ -964,8 +979,17 @@ function! s:update_finish()
         call s:log4(name, 'Checking out '.spec.commit)
         let out = s:checkout(spec)
       elseif has_key(spec, 'tag')
-        call s:log4(name, 'Checking out '.spec.tag)
-        let out = s:system('git checkout -q '.s:esc(spec.tag).' 2>&1', spec.dir)
+        let tag = spec.tag
+        if tag =~ '\*'
+          let tags = s:lines(s:system('git tag --list '.string(tag).' --sort -version:refname 2>&1', spec.dir))
+          if !v:shell_error && !empty(tags)
+            let tag = tags[0]
+            call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag))
+            call append(3, '')
+          endif
+        endif
+        call s:log4(name, 'Checking out '.tag)
+        let out = s:system('git checkout -q '.s:esc(tag).' 2>&1', spec.dir)
       else
         let branch = s:esc(get(spec, 'branch', 'master'))
         call s:log4(name, 'Merging origin/'.branch)
@@ -1809,10 +1833,7 @@ endfunction
 
 function! s:system(cmd, ...)
   try
-    let [sh, shrd] = [&shell, &shellredir]
-    if !s:is_win
-      set shell=sh shellredir=>%s\ 2>&1
-    endif
+    let [sh, shrd] = s:chsh(1)
     let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
     return system(s:is_win ? '('.cmd.')' : cmd)
   finally
@@ -2225,4 +2246,3 @@ endif
 
 let &cpo = s:cpo_save
 unlet s:cpo_save
-