浏览代码

trying to do my own template

Kevin Heinicke 10 年之前
父节点
当前提交
e23747e71d
共有 2 个文件被更改,包括 49 次插入15 次删除
  1. 42 0
      .zsh_custom/themes/bixel.zsh-theme
  2. 7 15
      .zshrc

+ 42 - 0
.zsh_custom/themes/bixel.zsh-theme

@@ -0,0 +1,42 @@
+# vim:ft=zsh ts=2 sw=2 sts=2
+# first approach to simple template using some functions from agnoster theme
+
+# Git: branch/detached head, dirty status
+prompt_git() {
+  local ref dirty mode repo_path
+  repo_path=$(git rev-parse --git-dir 2>/dev/null)
+
+  if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
+    dirty=$(parse_git_dirty)
+    ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git show-ref --head -s --abbrev |head -n1 2> /dev/null)"
+    if [[ -n $dirty ]]; then
+      prompt_segment yellow black
+    else
+      prompt_segment green black
+    fi
+
+    if [[ -e "${repo_path}/BISECT_LOG" ]]; then
+      mode=" <B>"
+    elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
+      mode=" >M<"
+    elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
+      mode=" >R>"
+    fi
+
+    setopt promptsubst
+    autoload -Uz vcs_info
+
+    zstyle ':vcs_info:*' enable git
+    zstyle ':vcs_info:*' get-revision true
+    zstyle ':vcs_info:*' check-for-changes true
+    zstyle ':vcs_info:*' stagedstr '✚'
+    zstyle ':vcs_info:git:*' unstagedstr '●'
+    zstyle ':vcs_info:*' formats ' %u%c'
+    zstyle ':vcs_info:*' actionformats ' %u%c'
+    vcs_info
+    echo -n "${ref/refs\/heads\// }${vcs_info_msg_0_%% }${mode}"
+  fi
+}
+
+PROMPT='[%~] '
+RPROMPT='[$(prompt_git)]'

+ 7 - 15
.zshrc

@@ -3,6 +3,8 @@
 ## Path to your oh-my-zsh installation.
 export ZSH=~/.oh-my-zsh
 
+export ZSH_CUSTOM=~/.zsh_custom
+
 # Set name of the theme to load.
 # Look in ~/.oh-my-zsh/themes/
 # Optionally, if you set this to "random", it'll load a random theme each
@@ -25,18 +27,8 @@ source $ZSH/oh-my-zsh.sh
 alias ll='ls -Fhla | less -R'
 alias l='ls -lhatr'
 
-# cool extract function
-function extract()
-{
-    if [ -f $1 ]; then
-        case $1 in
-            *.tar.bz2)  tar xvjf $1 ;;
-            *.tar.gz)   tar xvzf $1 ;;
-            *.tar)      tar xvf $1  ;;
-            *.zip)      unzip $1    ;;
-            *)          echo "'$1' cannot be extracted via extract()";;
-        esac
-    else
-        echo "'$1' is not a valid file!"
-    fi
-}
+# vi-mode ❤️ :O
+bindkey -v
+bindkey '^?' backward-delete-char
+bindkey '^w' backward-kill-word
+bindkey '^r' history-incremental-search-backward