Просмотр исходного кода

clean up a bit, add nocorrect mv, add tab to clearsearch in vim

Weiyi Lou 13 лет назад
Родитель
Сommit
bd1ebc35a8

+ 1 - 1
mongo/mongorc.js

@@ -1,4 +1,4 @@
 prompt = function() {
   var host = db.serverStatus().host;
-  return host.toUpperCase() + ":[" + db + "] > ";
+  return host + ":[" + db + "] > ";
 }

+ 7 - 6
vim/vimrc

@@ -190,9 +190,10 @@ nmap <silent> <leader><TAB>    :%s/<TAB>/  /g<CR>
 " Space as a folding toggle in normal mode.
 nmap <silent> <space>     @=(foldlevel('.')?'za':"\<space>")<CR>
 
-" Escape to CLEAR CURRENT SEARCH (and stop highlighting) in normal mode
-" TODO This messes with escape at the start of vim... any resolution?
-"nnoremap <silent> <ESC>    :call ClearSearch()<CR>
+" Tab to CLEAR CURRENT SEARCH (and stop highlighting) in normal mode
+" TODO would love to use <ESC> (more intuitive), but there are issues at vim
+" startup
+nmap <silent> <TAB>    :call ClearSearch()<CR>
 
 nmap <silent> <leader>n    :set number!<CR>
 nmap <silent> <leader>w    :set wrap!<CR>
@@ -216,14 +217,14 @@ nmap <silent> <leader>d    :NERDTreeToggle<CR>
 nmap <silent> <leader>,    :call NERDComment("n", "toggle")<CR>
 vmap <silent> <leader>,    <ESC>:call NERDComment("x", "toggle")<CR>
 
-" Traverse undo tree with Gundo!
+" Traverse undo tree with Gundo
 nmap <silent> <leader>u    :GundoToggle<CR>
 
-" Git blame with Fugitive!
+" Git blame and log with Fugitive
 nmap <silent> <leader>b    :Gblame<CR>
 nmap <silent> <leader>g    :Glog<CR><CR>
 
-" Code heirarchy with Tagbar!
+" Code heirarchy with Tagbar
 nmap <silent> <leader>t    :TagbarToggle<CR>
 
 

+ 31 - 22
zsh/omz-custom/cinaeco.zsh-theme

@@ -1,6 +1,7 @@
 ## Set tab title to hostname
 print -Pn "\e]1;`hostname | cut -d. -f1`\a"
-## multi line prompt
+
+## Multiline Prompt
 PROMPT='
 %{$fg[cyan]%}[%m]  %{$fg[yellow]%}%3~  $(git_prompt_info)
 %{$fg[magenta]%}%n → %{$reset_color%}'
@@ -27,9 +28,12 @@ ZSH_THEME_GIT_INDEX_COPIED="c"
 # FUNCTIONS
 ##############################
 
-## Override the default `git_prompt_info` function
-## Git commit id and mode code taken from:
-## https://github.com/benhoskings/dot-files/blob/master/files/bin/git_cwd_info
+# Display Git repo information in prompt (override the default omz function)
+#
+# Displays [repo_name:branch_name:commit_sha] MERGE/BISECT/REBASE x+changes+x
+#
+# Git commit id and mode code taken from:
+# https://github.com/benhoskings/dot-files/blob/master/files/bin/git_cwd_info
 function git_prompt_info() {
   GIT_REPO_PATH=$(git rev-parse --git-dir 2>/dev/null)
   [[ $GIT_REPO_PATH == "" ]] && return
@@ -51,17 +55,23 @@ function git_prompt_info() {
 }
 
 
-## Override the default `git_prompt_status` function
-## Preferably only use with multiline prompts
-## Try to print a each change instead of just indicating if each type exists.
-## This gives a better visual sense of how much has changed
-## Status is computed from the short version of git status that lists out
-##     xy filename1
-##     xy filename2
-## where x and y are statuses such as A (added), M (modified). Details in the
-## git-status manpage.
-## TODO Is this as fast as it gets? Maybe. The speed of this script appears to
-## be limited by the speed of --porcelain or -s in any given repo.
+# Git Change Indication (overriding default omz function)
+#
+# !!ONLY USE WITH MULTILINE PROMPTS!! as there can be a lot of symbols
+# (perhaps should limit to 20 or something)
+#
+# Prints symbol for each change instead of just indicating if a type exists.
+# This gives a better visual sense of how much has changed.
+#
+# TODO If you find prompt speed slow, it's because of this section.
+# The limitation is the speed of `git status` in any given repo (it's slower
+# than you'd imagine). The rest of the symbol computation is pretty much
+# instantaneous, even on older CPUs.
+# TODO should we make a way to toggle this on/off on the fly, to deal with
+# performance issues for ridiculous git repos?
+# TODO number of changes in git repo doesn't necessarily mean slow `git status`,
+# neither does it seem to definitely be caused by large number of files. When is
+# `git status` slow?
 git_prompt_status() {
   INDEX=$(git status --porcelain 2> /dev/null)
   [[ -z $INDEX ]] && return
@@ -86,13 +96,12 @@ git_prompt_status() {
   echo $STATUS
 }
 
-## Override the default `current_repository` function
-## Cope with non-ssh repos by not relying on ':'. Instead, we look for text
-## between a '/' and '.git'.
-##
-## We don't need to test if HEAD is a symbolic ref - that gets controlled in
-## git_prompt_info(). Unlike `current_branch` there are no oh-my-zsh shortcuts
-## that will be broken if we don't test for this.
+# Read the current repository (override the default omz function)
+#
+# Cope with non-ssh repos by not relying on ':'. Instead, we look for text
+# between a '/' and '.git'.
+# TODO should expand to search between '/' and space, if '.git' is not present.
+# Some people don't write their remotes properly.
 function current_repository() {
   echo $(git remote -v | head -1 | sed 's/.*\/\([^/]*\)\.git.*/\1/')
 }

+ 6 - 0
zsh/omz-custom/correction.zsh

@@ -1,4 +1,10 @@
 # Don't suggest corrections for these commands, in inclusion to omz's defaults
 alias cp='nocorrect cp'
+alias mv='nocorrect mv'
 alias ln='nocorrect ln'
 alias touch='nocorrect touch'
+
+# Stop zsh from completing with characters mid-word i.e. y completes to weiyi
+# I have found mid-word completion to be quite useful, so this is just here for
+# reference.
+# zstyle ':completion:*' matcher-list ''

+ 1 - 1
zsh/omz-custom/folder.zsh

@@ -1,4 +1,4 @@
-# folder listing/traversal
+# folder listing/traversal, least to most detailed
 alias l='ls'
 alias la='ls -A'
 alias ll='ls -lh'

+ 15 - 7
zsh/omz-custom/git.zsh

@@ -1,6 +1,7 @@
-## preferred git shortcuts not in the git plugin
-#
+# preferred git shortcuts, not in the git plugin
+
 alias ga.='git add .'
+
 alias gs='git status'
 alias gd='git diff'
 alias gds='git diff --staged'
@@ -10,24 +11,31 @@ alias gf='git fetch'
 
 alias gbd='git branch -D'
 
-## standard log with train tracks
+# standard log with train tracks
 alias gl='git log --graph --pretty="format:%C(yellow)%h%Cgreen%d %Cblue[%an] %Creset%s... %C(cyan)%ar"'
-## concise, branch-only log with train tracks
+# concise, branch and tag log with train tracks (some merge commits unavoidable)
 alias glb='git log --all --simplify-by-decoration --pretty="format:%C(yellow)%h%Cgreen%d %Cblue[%an] %Creset%s... %C(cyan)%ar"'
-## search through history for particular text
-alias glS='git log -S'
 alias glp='git log --patch'
+# useful when you want to have a visual on file changes
 alias gls='git log --graph --stat'
+# search through history for particular text
+alias glS='git log -S'
 
 alias gr='git reset'
 alias grh='git reset --hard'
 alias grs='git reset --soft'
 alias grb='git rebase'
 
+# useful for finding parent commit for a given commit hash
 alias gsr='git show --format=raw'
 
+# useful if you forget to setup tracking for a new branch when checking out.
 alias track='git branch --set-upstream $(current_branch) origin/$(current_branch) && git fetch'
 
-# useful git plugin built-in ones include:
+# useful omz git plugin ones include:
 #   ga, gc, gco, gb, gba, gm, grhh, ggpull, ggpush
+#
 # ggpull translates into `git pull origin <current branch>`, same for ggpush
+#
+# Note: both the gg's are extremely convenient! And safe, because you never know
+# if tracking has been setup properly on a branch.

+ 1 - 1
zsh/omz-custom/history.zsh

@@ -1,5 +1,5 @@
 ## history
-alias h='history'
+alias h='history 100'
 ## don't show expansions, just execute, e.g. for !! and !$
 setopt nohistverify
 ## don't have the same history across tabs/windows

+ 1 - 0
zsh/omz-custom/proxy.zsh

@@ -3,6 +3,7 @@
 # Thanks to:
 # https://github.com/dangerous/dotfiles
 #
+# TODO: The setting of the IP should be perhaps moved to a zshlocal file.
 alias proxy='export http_proxy=http://192.168.1.248:3128;export HTTP_PROXY=$http_proxy;export https_proxy=$http_proxy;export HTTPS_PROXY=$http_proxy;export ftp_proxy=$http_proxy;export FTP_PROXY=$http_proxy;'
 alias noproxy='export http_proxy='';export HTTP_PROXY=$http_proxy;export https_proxy=$http_proxy;export HTTPS_PROXY=$http_proxy;export ftp_proxy=$http_proxy;export FTP_PROXY=$http_proxy;'
 

+ 2 - 5
zsh/omz-custom/ssh-add.zsh

@@ -1,11 +1,8 @@
 # Add the first user identity if the local ssh-agent doesn't already have
 # something.
 #
-# Silence error output for when we're sshing to a machine that we don't want to
-# use ssh-agent forwarding for.
-#
-# This works well when there is only one identity. Don't know what
-# would happen if a person had more than one private key to use.
+# We silence error output for when we're sshing to a machine that we don't want
+# to use ssh-agent forwarding for.
 if [[ `ssh-add -l 2> /dev/null` != *id_?sa* ]]; then
   ssh-add 2> /dev/null
 fi

+ 1 - 1
zsh/omz-custom/tmux.zsh

@@ -2,6 +2,6 @@
 # https://github.com/altercation/solarized/issues/159
 # We need to force a TERM type for tmux
 # Ensure that the terminal emulator also reports TERM as 'screen-256color'
+# Seems to be needed separately for tmuxinator as well
 alias tmux='TERM=screen-256color tmux'
-# Seems to be needed for tmuxinator as well
 alias mux='TERM=screen-256color mux'