├── .projectile
├── .gitignore
├── Makefile
├── README.org
└── zshrc.org
/.projectile:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | zshrc.html
2 | zshrc.sh
3 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | FILES:="\"zshrc.org\""
2 | DIR:=$(shell pwd)
3 | ORGINSTALL:=${HOME}/.emacs.src.d/org-mode/lisp/
4 | SHELL:=zsh
5 |
6 | tangle:
7 | @emacs -Q --batch -L ${ORGINSTALL} \
8 | --eval "(progn \
9 | (require 'org) (require 'ob) (require 'ob-tangle) \
10 | (mapc (lambda (file) (find-file (expand-file-name file \"$(DIR)\")) (org-babel-tangle) (kill-buffer)) '($(FILES))))"
11 |
12 | externals:
13 | antibody bundle < ${HOME}/.zsh.d/plugins.txt > ${HOME}/.zsh.d/plugins.sh
14 | update-externals:
15 | antibody update
16 |
17 | .PHONY: tangle externals update-externals
18 |
--------------------------------------------------------------------------------
/README.org:
--------------------------------------------------------------------------------
1 | This repository moved to sourcehut: https://git.sr.ht/~tomterl/zshorg
2 |
3 | * My literate =zsh= configuration.
4 |
5 | This is my zsh configuration as [[http://orgmode.org/][org-mode]] document, based off of my
6 | previous [[https://github.com/robbyrussell/oh-my-zsh][oh-my-zsh]] setup. So the setup presented here is at the moment
7 | almost completly owed to the crazy and wonderful croud assambled
8 | there. And to Sven Guckes and Julius Plenz -- their book "zsh - Die
9 | magische Shell" is a helpful resource in setting up zsh.
10 |
11 | Not everything is explained in prose yet, but I'll get there, for my
12 | own good.
13 |
14 | This is, and will be, a work in progress. And somtime I hope a work of
15 | beauty.
16 |
17 | The whole configuration setup is in =zshrc.org=, the file is split
18 | during tangling.
19 |
20 | ** Prerequisites
21 | - emacs 24
22 | - org-mode >= 7.8.03 (exported after 23d january 2012)
23 | - make
24 |
25 | ** Installation
26 | - Clone the github repository
27 | #+BEGIN_SRC sh
28 | cd $HOME
29 | git clone git://github.com/tomterl/zshorg.git .zshorg
30 | #+END_SRC
31 |
32 | - Read the file =zshrc.org= and tinker with the settings.
33 |
34 | - Backup your existing config
35 | #+BEGIN_SRC sh
36 | mkdir -p ~/Backups
37 | tar cfvz ~/Backups/zsh-config-$(date +"%F-%T") ~/.zshrc ~/.zsh.d
38 | #+END_SRC
39 | - Generate the new config
40 | Either =C-c C-v C-t= while visiting the file =zshrc.org= in emacs, or
41 | #+BEGIN_SRC sh
42 | cd ~/.zshorg
43 | make tangle
44 | #+END_SRC
45 | this will overwrite =~/.zshrc= and a couple of files in =~/.zsh.d=;
46 | make sure you have backups. If you use the makefile, you have to
47 | tweak the =ORGINSTALL= variable or provide it at the commandline
48 | #+BEGIN_SRC sh
49 | cd ~/.zshorg
50 | make tangle ORGINSTALL=your/actual/path/to/the/org/elc/files
51 | #+END_SRC
52 | - Install external addons
53 | #+BEGIN_SRC sh
54 | make externals
55 | #+END_SRC
56 | ** External addons
57 | Addons resp. plugins are managed using ~antibody~. To update them issue ~make update-externals~.
58 |
59 | ** =org-mode= config :ingnoreExport:
60 | #+STARTUP: indent
61 | #+STARTUP: content
62 | #+EXPORT_EXCLUDE_TAGS: ignoreExport
63 |
--------------------------------------------------------------------------------
/zshrc.org:
--------------------------------------------------------------------------------
1 | * Introduction
2 | :LOGBOOK:
3 | - Note taken on [2012-01-30 Mo 11:53] \\
4 | tangle to the correct locations; use logbook drawer
5 | - Note taken on [2012-01-29 So 01:15] \\
6 | Git functions added; prompt added; html export style
7 | :END:
8 |
9 | This is a literate programming zsh configuration written in
10 | org-mode/org-babel.
11 |
12 | ** History
13 | Up until January 2012 I used [[https://github.com/robbyrussell/oh-my-zsh][oh-my-zsh]] to configure my shell
14 | environment. It contains a lot of good ideas and a plethora of tools
15 | but, it also contains many errors and small mistakes; the code-quality
16 | overall is lousy.
17 |
18 | After discovering the [[https://github.com/eschulte/emacs24-starter-kit][emacs starter kit]] I thought a lot about a good
19 | project to start to learn about and use [[http://orgmode.org/worg/org-contrib/babel/][org-babel]] for a literate
20 | programming adventure.
21 |
22 | I'm usualy slow to take action, considering a lot, thinking ahead as
23 | many paths as I can -- think of. Since, as of january 3d, oh-my-zsh
24 | get's on my nerves for a couple of weeks now instead of making my
25 | day, taking on my first LP project wasn't such a long process after all.
26 |
27 | The first version considered complete enough to replace oh-my-zsh,
28 | finaly ridden of the command substitution bug, was finished
29 | <2012-01-10 Tue 13:21>.
30 | ** =org-mode= configuration :ignoreExport:
31 | #+TITLE: zsh Configuration
32 | #+STARTUP: overview
33 | #+STARTUP: logdone
34 | #+STARTUP: indent
35 | #+PROPERTY: padline yes
36 | #+PROPERTY: LOG_INTO_DRAWER LOGBOOK
37 | #+EXPORT_EXCLUDE_TAGS: ignoreExport
38 | #+OPTIONS: H:3 num:t toc:t \n:nil @:t ::t |:t ^:nil -:t f:t *:t <:t
39 | #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil todo:t pri:nil tags:not-in-toc
40 | #+INFOJS_OPT: view:nil toc:t ltoc:t mouse:underline buttons:0 path:http://orgmode.org/org-info.js
41 | #+STYLE:
42 | * =zshrc=
43 | #+BEGIN_SRC sh :tangle ~/.zshrc :noweb tangle :exports code
44 | <>
45 | <>
46 | <>
47 | <>
48 | <>
49 | <>
50 | <>
51 | <>
52 | <>
53 | <>
54 | <>
55 | <>
56 | <>
57 | <>
58 | <>
59 | <>
60 | <>
61 | #+END_SRC
62 |
63 | ** Variables
64 | :PROPERTIES:
65 | :header-args: :noweb-ref variables
66 | :header-args: :padline yes
67 | :END:
68 |
69 | *** Emacs setup
70 |
71 | On different systems emacs 24 will be installed in different
72 | locations; I set =EMACS_BASE= here; aliases etc. later will use it.
73 |
74 | #+BEGIN_SRC sh
75 | if [ -z "${EMACS_BASE}" ]; then
76 | EMACS_BASE="/usr/local"
77 | export EMACS_BASE
78 | fi
79 | #+END_SRC
80 | **** Emacs cask
81 | #+BEGIN_SRC sh
82 | # emacs cask package/dev managment
83 | export PATH="$HOME/.cask/bin:$PATH"
84 | #+END_SRC
85 |
86 | *** Coloring for standard commands
87 | Use =green= for matches, not =red=.
88 | #+BEGIN_SRC sh
89 | export GREP_COLORS="mt=01;32:ms=01;32:mc=01;32:sl=:cx=:fn=35:ln=32:bn=32:se=36"
90 | #+END_SRC
91 |
92 | *** Pager
93 | #+BEGIN_SRC sh
94 | export PAGER='less'
95 | #+END_SRC
96 |
97 | *** Characterset
98 | #+BEGIN_SRC sh
99 | export LC_CTYPE=$LANG
100 | #+END_SRC
101 |
102 | *** Path/Fpath
103 | Newest GNU R in ~/opt
104 | #+BEGIN_SRC sh
105 | path=( ~/opt/bin $path )
106 | #+END_SRC
107 |
108 | Haskell development.
109 | #+BEGIN_SRC sh
110 | path=( ~/.cabal/bin $path )
111 | #+END_SRC
112 | This should always be the last part of =path= tinkering, as I'm used
113 | to be able to override any executable by putting a replacement or
114 | wrapper in my =~/bin=.
115 | #+BEGIN_SRC sh
116 | path=( ~/bin $path )
117 | #+END_SRC
118 | Finaly adjust the =fpath=; a lot of the stuff following is tangled
119 | into files autoloadable, and I use ~wd~ for easier filesystem navigation
120 | #+BEGIN_SRC sh
121 | fpath=( ~/bin/wd.zsh $fpath)
122 | fpath=( ~/.zsh.d/functions $fpath )
123 | #+END_SRC
124 | **** ~wd~ function
125 | #+BEGIN_SRC sh
126 | wd() {
127 | . ~/bin/wd.zsh/wd.sh
128 | }
129 | #+END_SRC
130 | #
131 | **** Ruby
132 | ***** =rvm=
133 | #+BEGIN_SRC sh
134 | # Add RVM to PATH for scripting
135 | PATH=$PATH:$HOME/.rvm/bin
136 | #+END_SRC
137 |
138 | *** Bashlibs
139 | #+BEGIN_SRC sh
140 | export BASH_LIBS_DIR=~/lib/bash
141 | #+END_SRC
142 |
143 | *** Editor
144 | #+BEGIN_SRC sh
145 | export EDITOR="${EMACS_BASE}/bin/emacsclient -nw -c"
146 | #+END_SRC
147 |
148 | *** Java and tiling WMs
149 | #+BEGIN_SRC sh
150 | export _JAVA_AWT_WM_NONREPARENTING=1
151 | #+END_SRC
152 | *** Vagrant
153 | #+BEGIN_SRC sh
154 | export WEBDEV_ROOT="~/Projekte/devserver/"
155 | #+END_SRC
156 | *** Arduino / Kaleidoscope
157 | #+BEGIN_SRC sh
158 | export ARDUINO_PATH=/usr/share/arduino
159 | export SKETCHBOOK_DIR=${HOME}/Arduino
160 | #+END_SRC
161 | *** Desktop Keyring variables
162 | #+BEGIN_SRC sh
163 | export $( dex /etc/xdg/autostart/gnome-keyring-ssh.desktop )
164 | #+END_SRC
165 | ** Modules
166 | :PROPERTIES:
167 | :header-args: :noweb-ref modules
168 | :END:
169 |
170 | *** =colors=
171 | #+BEGIN_SRC sh
172 | autoload colors; colors
173 | #+END_SRC
174 |
175 | ** Aliases
176 | :PROPERTIES:
177 | :header-args: :noweb-ref aliases
178 | :END:
179 | *** Coloring for standard commands
180 | A few standard aliases to deal with colored output in terminals.
181 | #+BEGIN_SRC sh
182 | [ ! -L ~/bin/ls ] && alias ls='/opt/coreutils/bin/ls --color=auto'
183 | alias grep='grep --color=auto'
184 | alias less='less -R'
185 | #+END_SRC
186 | *** Emacs
187 | My emacs installation is sometimes in special locations; the aliases
188 | defined here reflect that.
189 |
190 | #+BEGIN_SRC sh
191 | alias emacs="${EMACS_BASE}/bin/emacs"
192 | alias emc="${EMACS_BASE}/bin/emacsclient -c -nw"
193 | #+END_SRC
194 | *** Desktop
195 | I use awesome and don't want =nautilus= to take over my desktop.
196 | Defining this alias prevents the =nautilus= started by
197 | =gnome-session= to automaticaly take over.
198 |
199 | #+BEGIN_SRC sh
200 | alias nautilus='nautilus --no-desktop'
201 | #+END_SRC
202 | *** vagrant ssh
203 | #+BEGIN_SRC sh
204 | alias vssh="pushd ${WEBDEV_ROOT} && docker exec -it devserver /bin/bash; popd"
205 | #+END_SRC
206 | *** tmux update-env
207 | #+BEGIN_SRC sh
208 | alias tue="tmux update-environment"
209 | #+END_SRC
210 | *** system log with lnav
211 | #+BEGIN_SRC sh
212 | alias syslog="journalctl -f -o json | lnav"
213 | #+END_SRC
214 | ** Functions
215 | :PROPERTIES:
216 | :header-args: :noweb-ref functions
217 | :END:
218 | *** Archives
219 | **** Extract
220 | #+BEGIN_SRC sh
221 | function extract() {
222 | unset REMOVE_ARCHIVE
223 |
224 | if test "$1" = "-r"; then
225 | REMOVE_ARCHIVE=1
226 | shift
227 | fi
228 | if [[ -f $1 ]]; then
229 | case $1 in
230 | *.tar.bz2) tar xvjf $1;;
231 | *.tar.gz) tar xvzf $1;;
232 | *.tar.xz) tar xvJf $1;;
233 | *.tar.lzma) tar --lzma -xvf $1;;
234 | *.bz2) bunzip $1;;
235 | *.rar) unrar x $1;;
236 | *.gz) gunzip $1;;
237 | *.tar) tar xvf $1;;
238 | *.tbz2) tar xvjf $1;;
239 | *.tgz) tar xvzf $1;;
240 | *.zip) unzip $1;;
241 | *.Z) uncompress $1;;
242 | *.7z) 7z x $1;;
243 | *) echo "'$1' cannot be extracted via >extract<";;
244 | esac
245 |
246 | if [[ $REMOVE_ARCHIVE -eq 1 ]]; then
247 | echo removing "$1";
248 | /bin/rm "$1";
249 | fi
250 |
251 | else
252 | echo "'$1' is not a valid file"
253 | fi
254 | }
255 | #+END_SRC
256 |
257 | *** Source bash scripts
258 | #+BEGIN_SRC sh
259 | bash_source() {
260 | alias shopt=':'
261 | alias _expand=_bash_expand
262 | alias _complete=_bash_comp
263 | emulate -L sh
264 | setopt kshglob noshglob braceexpand
265 |
266 | source "$@"
267 | }
268 | #+END_SRC
269 |
270 | *** Date from unix timestamp
271 | #+BEGIN_SRC sh
272 | function fromut() {
273 | echo `perl -e "print scalar(localtime(${1})),\"\n\";"`
274 | }
275 | #+END_SRC
276 |
277 |
278 | *** SSH host keys
279 | #+BEGIN_SRC sh
280 | function remove_host_keys() {
281 | host="${1}"
282 | if [ -n "${host}" ]; then
283 | ssh-keygen -f "${HOME}/.ssh/known_hosts" -R "${host}"
284 | else
285 | echo "remove_host_keys {IP|HOST}" > /dev/stderr
286 | fi
287 | }
288 | #+END_SRC
289 | *** ~phpunit~
290 | #+BEGIN_SRC sh
291 | function phpunit() {
292 | command phpunit ${@}
293 | printf '\xb10m'
294 | }
295 | #+END_SRC
296 | *** Compress jpeg-Files via ~convert~
297 | #+BEGIN_SRC sh
298 | function compress_jpeg() {
299 | for pic in "${@}"; do
300 | convert -strip -interlace Plane -gaussian-blur 0.05 -quality 85% "${pic}" "${pic}"
301 | done
302 | }
303 | #+END_SRC
304 | *** Check for null-bytes
305 | #+BEGIN_SRC sh
306 | function check_zero_bytes() {
307 | status=0
308 | for arg in "${@}"; do
309 | perl -ne '/\000/ and print' "${arg}"
310 | status=1
311 | done
312 | return $status
313 | }
314 | #+END_SRC
315 | ** Options
316 | :PROPERTIES:
317 | :header-args: :noweb-ref options
318 | :END:
319 | #+BEGIN_SRC sh
320 | setopt extended_glob \
321 | glob_complete \
322 | function_arg_zero \
323 | hash_cmds \
324 | hash_dirs \
325 | multios \
326 | re_match_pcre
327 | #+END_SRC
328 |
329 | ** Keybindings
330 | :PROPERTIES:
331 | :header-args: :noweb-ref keybindings
332 | :END:
333 | *** Emacs style keybindings!
334 | #+BEGIN_SRC sh
335 | bindkey -e
336 | #+END_SRC
337 | ** Command completion
338 | :PROPERTIES:
339 | :header-args: :noweb-ref command_completion
340 | :END:
341 | *** =compinit=
342 | #+BEGIN_SRC sh
343 | autoload -Uz compinit; compinit
344 | #+END_SRC
345 |
346 | *** Options
347 | #+BEGIN_SRC sh
348 | unsetopt menu_complete \
349 | flowcontrol
350 |
351 | setopt auto_menu \
352 | complete_in_word \
353 | always_to_end
354 | #+END_SRC
355 | *** =complist= module
356 | #+BEGIN_SRC sh
357 | zmodload -i zsh/complist
358 | #+END_SRC
359 |
360 | *** .zshrc
361 | #+BEGIN_SRC sh
362 | zstyle :compinstall filename "$HOME/.zshrc"
363 | #+END_SRC
364 |
365 | *** Bashcompletion
366 | #+BEGIN_SRC sh
367 | autoload -Uz bashcompinit; bashcompinit
368 | #+END_SRC
369 |
370 | *** Case sensitive, partial word and substring completion
371 | #+BEGIN_SRC sh
372 | zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
373 | #+END_SRC
374 | *** Colors/Menu
375 | #+BEGIN_SRC sh
376 | zstyle ':completion:*' list-colors ''
377 | zstyle ':completion:*:*:*:*:*' menu select
378 | #+END_SRC
379 | *** Keybindings
380 | #+BEGIN_SRC sh
381 | bindkey -M menuselect '^o' accept-and-infer-next-history
382 | #+END_SRC
383 | *** Process completion
384 | Menu of own processes for kill.
385 | #+BEGIN_SRC sh
386 | zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
387 | zstyle ':completion:*:*:*:*:processes' command "ps -u $(whoami) -o pid,user,comm -w -w"
388 | #+END_SRC
389 | *** Hostnames
390 | #+BEGIN_SRC sh
391 | [ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(...>${CMD_2}%<<"
700 | }
701 |
702 | add-zsh-hook precmd omz_termsupport_precmd
703 | add-zsh-hook preexec omz_termsupport_preexec
704 |
705 | #+END_SRC
706 |
707 | *** ~tmux~
708 | tmux wrapper that adds new commands to update environment variables in running panes/windows
709 | #+BEGIN_SRC sh
710 | function tmux() {
711 | case "$1" in
712 | update-environment|update-env|env-update)
713 | local v
714 | command tmux show-environment | while read v; do
715 | if [[ "$v" == -* ]]; then
716 | unset ${v/#-/}
717 | else
718 | # Add quotes around the argument
719 | v=${v/=/\=\"}
720 | v=${v/%/\"}
721 | eval export $v
722 | fi
723 | done
724 | ;;
725 | *)
726 | command tmux "$@"
727 | ;;
728 | esac
729 | }
730 | #+END_SRC
731 | ** Prompt
732 | :PROPERTIES:
733 | :header-args: :noweb-ref prompt
734 | :END:
735 | *** Module
736 | #+BEGIN_SRC sh
737 | autoload -U promptinit; promptinit
738 | #+END_SRC
739 |
740 | #+BEGIN_SRC sh
741 | autoload -Uz vcs_info
742 | zstyle ':vcs_info:*' enable git svn
743 | precmd() {
744 | vcs_info
745 | }
746 | #+END_SRC
747 |
748 | #+BEGIN_SRC sh
749 | setopt prompt_subst
750 | #+END_SRC
751 |
752 | *** Configure theme
753 |
754 | **** Load all the icons...
755 | #+BEGIN_SRC sh
756 | if [ -f ~/.local/share/icons-in-terminal/icons_bash.sh ]; then
757 | . ~/.local/share/icons-in-terminal/icons_bash.sh
758 | elif [ -f /usr/share/icons-in-terminal/icons_bash.sh ]; then
759 | . /usr/share/icons-in-terminal/icons_bash.sh
760 | fi
761 | #+END_SRC
762 |
763 | **** ~php~ block
764 |
765 | Do not show the ~nodejs~ block, show our new shiny php block instead.
766 |
767 | #+BEGIN_SRC sh
768 | BLOX_BLOCK__PHP_SYMBOL="${BLOX_BLOCK__PHP_SYMBOL:-${file_php:-php} }"
769 | BLOX_BLOCK__PHP_COLOR="${BLOX_BLOCK__PHP_COLOR:-green}"
770 | function blox_block__php() {
771 | if [ -n "$(find_root "$PWD" RoboFile.php)" ]; then
772 | PHPV=$(php --version | head -n 1 | cut -d- -f1 | sed 's/PHP //' | cut -d\ -f1)
773 | blox_helper__build_block \
774 | "${BLOX_BLOCK__PHP_COLOR}" \
775 | "${BLOX_BLOCK__PHP_SYMBOL}${PHPV}"
776 | fi
777 | }
778 | export BLOX_SEG__UPPER_RIGHT=( bgjobs php pyenv virtualenv time )
779 | #+END_SRC
780 |
781 |
782 | ** GNU global
783 | :PROPERTIES:
784 | :noweb-ref: gnuglobal
785 | :END:
786 | #+BEGIN_SRC sh
787 | export GTAGSCONF=/usr/local/share/gtags/gtags.conf
788 | export GTAGSLABEL=pygments
789 | #+END_SRC
790 |
791 | ** Groovy
792 | :PROPERTIES:
793 | :noweb-ref: groovy
794 | :END:
795 | #+BEGIN_SRC sh
796 | source ~/.gvm/bin/gvm-init.sh
797 | #+END_SRC
798 | ** Git
799 | :PROPERTIES:
800 | :header-args: :noweb-ref git
801 | :END:
802 | *** Prompt
803 | If there is on thing I had to name, that made me crave for oh-my-zsh
804 | it was the right site prompt stating repository state; here are the
805 | functions I ripped from it...
806 | #+BEGIN_SRC sh
807 | function git_prompt_info() {
808 | ref=$(git symbolic-ref HEAD 2> /dev/null) || return
809 | echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
810 | }
811 |
812 | function parse_git_dirty() {
813 | if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
814 | echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
815 | else
816 | echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
817 | fi
818 | }
819 |
820 | function git_prompt_ahead() {
821 | if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
822 | echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
823 | fi
824 | }
825 |
826 | function git_prompt_short_sha() {
827 | SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
828 | }
829 |
830 | function git_prompt_long_sha() {
831 | SH A=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
832 | }
833 |
834 | function git_prompt_status() {
835 | INDEX=$(git status --porcelain 2> /dev/null)
836 | STATUS=""
837 | if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
838 | STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
839 | fi
840 | if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
841 | STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
842 | elif $(echo "$INDEX" | grep '^M ' &> /dev/null); then
843 | STATUS="$ZSH_THEME_GIT_PROMPT_ADDED$STATUS"
844 | fi
845 | if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then
846 | STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
847 | elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then
848 | STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
849 | elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then
850 | STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS"
851 | fi
852 | if $(echo "$INDEX" | grep '^R ' &> /dev/null); then
853 | STATUS="$ZSH_THEME_GIT_PROMPT_RENAMED$STATUS"
854 | fi
855 | if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
856 | STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
857 | elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
858 | STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
859 | fi
860 | if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
861 | STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
862 | fi
863 | echo $STATUS
864 | }
865 |
866 | #+END_SRC
867 |
868 | *** Commands
869 | #+BEGIN_SRC sh
870 | autoload -Uz gitaliasinit; gitaliasinit
871 | autoload -Uz find_root
872 | #+END_SRC
873 | ** Build packages
874 | :PROPERTIES:
875 | :header-args: :noweb-ref packages
876 | :END:
877 | #+BEGIN_SRC sh
878 | autoload -Uz stumpdeb
879 | #+END_SRC
880 | * =zlogin=
881 | #+BEGIN_SRC sh :tangle ~/.zlogin
882 | # Load RVM into a shell session *as a function
883 | [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
884 | if [ "$0" = "/usr/sbin/lightdm-session" -a "$DESKTOP_SESSION" = "i3" ]; then
885 | export $(gnome-keyring-daemon -s)
886 | fi
887 | #+END_SRC
888 | * Library
889 | :PROPERTIES:
890 | :mkdirp: yes
891 | :END:
892 | ** Plugins
893 | *** Write plugin list
894 | #+BEGIN_SRC sh :tangle ~/.zsh.d/plugins.txt
895 | yardnsm/blox-zsh-theme
896 | hlissner/zsh-autopair
897 | zsh-users/zsh-completions
898 | zsh-users/zsh-autosuggestions
899 | zsh-users/zsh-history-substring-search
900 | zsh-users/zsh-syntax-highlighting
901 | #+END_SRC
902 | *** source the generated shell-file
903 | #+BEGIN_SRC sh :tangle ~/.zshrc
904 | [ -f ~/.zsh.d/plugins.sh ] && source ~/.zsh.d/plugins.sh
905 | #+END_SRC
906 | ** Git
907 | *** Init
908 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/gitaliasinit
909 | _GITALIAS_DIR=${:-~/.zsh.d/functions/git}
910 | gitaliasinit() {
911 | fpath=($_GITALIAS_DIR $fpath)
912 | for gitalias in $_GITALIAS_DIR/*; do
913 | if [[ -r $gitalias ]]; then
914 | name=$gitalias:t
915 | autoload -Uz $name
916 | fi
917 | done
918 | }
919 |
920 | [[ -o kshautoload ]] || gitaliasinit "$@"
921 | #+END_SRC
922 |
923 |
924 | *** Add
925 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/add
926 | git add "${argv[@]}"
927 | #+END_SRC
928 | *** Commit
929 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/commit
930 | git commit "${argv[@]}"
931 | #+END_SRC
932 | *** Diff
933 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/gdiff
934 | git diff "${argv[@]}"
935 | #+END_SRC
936 | *** Log
937 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/glog
938 | git log "${argv[@]}"
939 | #+END_SRC
940 | *** Stat
941 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/gstat
942 | git status "${argv[@]}"
943 | #+END_SRC
944 | *** TODO Pull
945 | The normal git pull
946 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/pull
947 | git pull "${argv[@]}"
948 | #+END_SRC
949 |
950 | Update a local branch from updated master
951 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/update_local
952 | checkout master && pull && checkout local && git merge master
953 | #+END_SRC
954 | Update org-mode from maint, not master
955 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/update_org
956 | checkout maint && pull && checkout local && git merge maint
957 | #+END_SRC
958 |
959 | *** Push
960 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/push
961 | git push "${argv[@]}"
962 | #+END_SRC
963 | *** Checkout
964 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/checkout
965 | git checkout "${argv[@]}"
966 | #+END_SRC
967 | *** Clone
968 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/git/clone
969 | git clone "${argv[@]}"
970 | #+END_SRC
971 | ** Installation/Packaging
972 | *** =stumpwm=
973 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/stumpdeb
974 | pushd ~/Projekte/stumpwm-contrib/
975 | git pull
976 | popd
977 | pushd ~/Projekte/stumpwm
978 | mkdir -p usr/local/bin
979 | mkdir -p usr/local/share/stumpwm/lisp
980 | mkdir -p usr/local/share/info
981 | cp stumpwm usr/local/bin
982 | find ~/Projekte/stumpwm-contrib -maxdepth 1 -mindepth 1 -name '[a-z]*' -type d -print0 | xargs -0 -ILISP cp -a LISP usr/local/share/stumpwm/lisp/
983 | cp stumpwm.info usr/local/share/info/
984 | gzip usr/local/share/info/stumpwm.info
985 | fpm -t deb -s dir -n stumpwm -v $(date +"%Y%m%d") -d sbcl usr/
986 | popd
987 | #+END_SRC
988 |
989 | ** Project tools
990 | *** find project root
991 | #+BEGIN_SRC sh :tangle ~/.zsh.d/functions/find_root
992 | local look_from=${1:-$PWD}
993 | local look_for=${2:-}
994 | local look_until=${${3:-/}:A}
995 |
996 | # Manually look in parent dirs. An extended Zsh glob should use Y1 for
997 | # # performance reasons, which is only available in zsh-5.0.5-146-g9381bb6.
998 | local last
999 | local parent_dir="$look_from"
1000 | local abs_parent_dir
1001 | while true; do
1002 | abs_parent_dir=${parent_dir:A}
1003 | if [[ $abs_parent_dir == $last ]]; then
1004 | break
1005 | fi
1006 | local parent_file="${parent_dir}/${look_for}"
1007 |
1008 | if [[ -f $parent_file ]]; then
1009 | if [[ ${parent_file[1,2]} == './' ]]; then
1010 | echo ${parent_file#./}
1011 | else
1012 | echo ${parent_file:a}
1013 | fi
1014 | break
1015 | fi
1016 |
1017 | if [[ $abs_parent_dir == $look_until ]]; then
1018 | break
1019 | fi
1020 | last=$abs_parent_dir
1021 | parent_dir="${parent_dir}/.."
1022 | done
1023 | #+END_SRC
1024 |
--------------------------------------------------------------------------------