Browse code
Add todo plugin, split out stuff from zshrc
Showing 6 changed files
- zsh_plugins/00-dircolors.sh
- zsh_plugins/00-utils.zsh
- zsh_plugins/98-todo.zsh
- zsh_plugins/99-interaction.zsh
- zsh_plugins/99-path-setup.zsh
- zsh_plugins/99-zzz.zsh
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,11 @@ |
1 |
+if [[ $TERM != 'dumb' ]]; then |
|
2 |
+ # Solarized dircolors: |
|
3 |
+ CLICOLOR=1 |
|
4 |
+ LS_COLORS='no=00;38;5;244:rs=0:di=00;38;5;33:ln=00;38;5;37:mh=00:pi=48;5;230;38;5;136;01:so=48;5;230;38;5;136;01:do=48;5;230;38;5;136;01:bd=48;5;230;38;5;244;01:cd=48;5;230;38;5;244;01:or=48;5;235;38;5;160:su=48;5;160;38;5;230:sg=48;5;136;38;5;230:ca=30;41:tw=48;5;64;38;5;230:ow=48;5;235;38;5;33:st=48;5;33;38;5;230:ex=00;38;5;64:*.tar=00;38;5;61:*.tgz=00;38;5;61:*.arj=00;38;5;61:*.taz=00;38;5;61:*.lzh=00;38;5;61:*.lzma=00;38;5;61:*.tlz=00;38;5;61:*.txz=00;38;5;61:*.zip=00;38;5;61:*.z=00;38;5;61:*.Z=00;38;5;61:*.dz=00;38;5;61:*.gz=00;38;5;61:*.lz=00;38;5;61:*.xz=00;38;5;61:*.bz2=00;38;5;61:*.bz=00;38;5;61:*.tbz=00;38;5;61:*.tbz2=00;38;5;61:*.tz=00;38;5;61:*.deb=00;38;5;61:*.rpm=00;38;5;61:*.jar=00;38;5;61:*.rar=00;38;5;61:*.ace=00;38;5;61:*.zoo=00;38;5;61:*.cpio=00;38;5;61:*.7z=00;38;5;61:*.rz=00;38;5;61:*.apk=00;38;5;61:*.gem=00;38;5;61:*.jpg=00;38;5;136:*.JPG=00;38;5;136:*.jpeg=00;38;5;136:*.gif=00;38;5;136:*.bmp=00;38;5;136:*.pbm=00;38;5;136:*.pgm=00;38;5;136:*.ppm=00;38;5;136:*.tga=00;38;5;136:*.xbm=00;38;5;136:*.xpm=00;38;5;136:*.tif=00;38;5;136:*.tiff=00;38;5;136:*.png=00;38;5;136:*.PNG=00;38;5;136:*.svg=00;38;5;136:*.svgz=00;38;5;136:*.mng=00;38;5;136:*.pcx=00;38;5;136:*.dl=00;38;5;136:*.xcf=00;38;5;136:*.xwd=00;38;5;136:*.yuv=00;38;5;136:*.cgm=00;38;5;136:*.emf=00;38;5;136:*.eps=00;38;5;136:*.CR2=00;38;5;136:*.ico=00;38;5;136:*.tex=00;38;5;245:*.rdf=00;38;5;245:*.owl=00;38;5;245:*.n3=00;38;5;245:*.ttl=00;38;5;245:*.nt=00;38;5;245:*.torrent=00;38;5;245:*.xml=00;38;5;245:*Makefile=00;38;5;245:*Rakefile=00;38;5;245:*Dockerfile=00;38;5;245:*build.xml=00;38;5;245:*rc=00;38;5;245:*1=00;38;5;245:*.nfo=00;38;5;245:*README=00;38;5;245:*README.txt=00;38;5;245:*readme.txt=00;38;5;245:*.md=00;38;5;245:*README.markdown=00;38;5;245:*.ini=00;38;5;245:*.yml=00;38;5;245:*.cfg=00;38;5;245:*.conf=00;38;5;245:*.c=00;38;5;245:*.cpp=00;38;5;245:*.cc=00;38;5;245:*.sqlite=00;38;5;245:*.go=00;38;5;245:*.log=00;38;5;240:*.bak=00;38;5;240:*.aux=00;38;5;240:*.lof=00;38;5;240:*.lol=00;38;5;240:*.lot=00;38;5;240:*.out=00;38;5;240:*.toc=00;38;5;240:*.bbl=00;38;5;240:*.blg=00;38;5;240:*~=00;38;5;240:*#=00;38;5;240:*.part=00;38;5;240:*.incomplete=00;38;5;240:*.swp=00;38;5;240:*.tmp=00;38;5;240:*.temp=00;38;5;240:*.o=00;38;5;240:*.pyc=00;38;5;240:*.class=00;38;5;240:*.cache=00;38;5;240:*.aac=00;38;5;166:*.au=00;38;5;166:*.flac=00;38;5;166:*.mid=00;38;5;166:*.midi=00;38;5;166:*.mka=00;38;5;166:*.mp3=00;38;5;166:*.mpc=00;38;5;166:*.ogg=00;38;5;166:*.ra=00;38;5;166:*.wav=00;38;5;166:*.m4a=00;38;5;166:*.axa=00;38;5;166:*.oga=00;38;5;166:*.spx=00;38;5;166:*.xspf=00;38;5;166:*.mov=00;38;5;166:*.MOV=00;38;5;166:*.mpg=00;38;5;166:*.mpeg=00;38;5;166:*.m2v=00;38;5;166:*.mkv=00;38;5;166:*.ogm=00;38;5;166:*.mp4=00;38;5;166:*.m4v=00;38;5;166:*.mp4v=00;38;5;166:*.vob=00;38;5;166:*.qt=00;38;5;166:*.nuv=00;38;5;166:*.wmv=00;38;5;166:*.asf=00;38;5;166:*.rm=00;38;5;166:*.rmvb=00;38;5;166:*.flc=00;38;5;166:*.avi=00;38;5;166:*.fli=00;38;5;166:*.flv=00;38;5;166:*.gl=00;38;5;166:*.m2ts=00;38;5;166:*.divx=00;38;5;166:*.webm=00;38;5;166:*.axv=00;38;5;166:*.anx=00;38;5;166:*.ogv=00;38;5;166:*.ogx=00;38;5;166:'; |
|
5 |
+ export LS_COLORS CLICOLOR LSCOLORS |
|
6 |
+ if command -v "${GNU_PREFIX}ls" 2>&1 > /dev/null; then |
|
7 |
+ ls() { |
|
8 |
+ "${GNU_PREFIX}ls" --color=auto "$@" |
|
9 |
+ } |
|
10 |
+ fi |
|
11 |
+fi |
... | ... |
@@ -1,13 +1,19 @@ |
1 | 1 |
add_exe_path() { |
2 |
- export PATH="$PATH:$1" |
|
2 |
+ if [[ -d $1 ]]; then |
|
3 |
+ export PATH="$PATH:$1" |
|
4 |
+ fi |
|
3 | 5 |
} |
4 | 6 |
|
5 | 7 |
push_exe_path() { |
6 |
- export PATH="$PATH:$1" |
|
8 |
+ if [[ -d $1 ]]; then |
|
9 |
+ export PATH="$PATH:$1" |
|
10 |
+ fi |
|
7 | 11 |
} |
8 | 12 |
|
9 | 13 |
prepend_exe_path() { |
10 |
- export PATH="$1:$PATH" |
|
14 |
+ if [[ -d $1 ]]; then |
|
15 |
+ export PATH="$1:$PATH" |
|
16 |
+ fi |
|
11 | 17 |
} |
12 | 18 |
|
13 | 19 |
mkcd() { |
14 | 20 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,61 @@ |
1 |
+TODO_DIR="$HOME/.todos" |
|
2 |
+ |
|
3 |
+if [[ ! -d "$TODO_DIR" ]]; then |
|
4 |
+ mkdir -p "$TODO_DIR"/{shells,archive} |
|
5 |
+fi |
|
6 |
+ |
|
7 |
+ds() { |
|
8 |
+ local task |
|
9 |
+ if [[ $# > 0 ]]; then |
|
10 |
+ task="$@" |
|
11 |
+ else |
|
12 |
+ read -r task\?'What doing? ' |
|
13 |
+ fi |
|
14 |
+ printf '%s' "$task" > "$TODO_DIR/shells/$$.txt" |
|
15 |
+} |
|
16 |
+ |
|
17 |
+td() { |
|
18 |
+ local task |
|
19 |
+ if [[ $# > 0 ]]; then |
|
20 |
+ task="$@" |
|
21 |
+ else |
|
22 |
+ read -r task\?'What doing? ' |
|
23 |
+ fi |
|
24 |
+ printf '%s' "$task" > "$TODO_DIR/current" |
|
25 |
+} |
|
26 |
+ |
|
27 |
+pop-todo() { |
|
28 |
+ local shell_file day_file |
|
29 |
+ shell_file="$TODO_DIR/shells/$$.txt" |
|
30 |
+ day_file="$TODO_DIR/current" |
|
31 |
+ |
|
32 |
+ if [[ -f "$shell_file" ]]; then |
|
33 |
+ mv "$shell_file" "$TODO_DIR/archive/$$.$(date +"%Y-%m-%d--%H-%M-%S")" |
|
34 |
+ return |
|
35 |
+ fi |
|
36 |
+ |
|
37 |
+ if [[ -f "$day_file" ]]; then |
|
38 |
+ mv "$day_file" "$TODO_DIR/archive/current.$(date +"%Y-%m-%d--%H-%M-%S")" |
|
39 |
+ return |
|
40 |
+ fi |
|
41 |
+} |
|
42 |
+ |
|
43 |
+doing() { |
|
44 |
+ local shell_file day_file |
|
45 |
+ shell_file="$TODO_DIR/shells/$$.txt" |
|
46 |
+ day_file="$TODO_DIR/current" |
|
47 |
+ |
|
48 |
+ if [[ -f "$shell_file" || -f "$day_file" ]]; then |
|
49 |
+ printf '\033[0;33mTODO: \033[0m' |
|
50 |
+ fi |
|
51 |
+ |
|
52 |
+ if [[ -f "$shell_file" ]]; then |
|
53 |
+ cat "$shell_file" | tr '\n' ' ' |
|
54 |
+ elif [[ -f "$day_file" ]]; then |
|
55 |
+ cat "$day_file" | tr '\n' ' ' |
|
56 |
+ fi |
|
57 |
+ |
|
58 |
+ if [[ -f "$shell_file" || -f "$day_file" ]]; then |
|
59 |
+ echo |
|
60 |
+ fi |
|
61 |
+} |
0 | 62 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,90 @@ |
1 |
+if [[ -e /etc/sysconfig/zsh-prompt-$TERM ]]; then |
|
2 |
+ . /etc/sysconfig/zsh-prompt-$TERM |
|
3 |
+elif [[ -e $HOME/.zsh-prompt-$TERM ]]; then |
|
4 |
+ . $HOME/.zsh-prompt-$TERM |
|
5 |
+fi |
|
6 |
+ |
|
7 |
+function battery_charge() { |
|
8 |
+ if [[ -x "$HOME/bin/batcharge.py" ]]; then |
|
9 |
+ if [[ $LAPTOP[1] == 'y' && $TERM != "xterm" ]]; then |
|
10 |
+ python "$HOME/bin/batcharge.py" 2>/dev/null |
|
11 |
+ fi |
|
12 |
+ else |
|
13 |
+ return 1 |
|
14 |
+ fi |
|
15 |
+} |
|
16 |
+ |
|
17 |
+zstyle ':vcs_info:*' actionformats \ |
|
18 |
+ '%F{5}%f%s%F{5}%F{3}->%F{5}%F{2}%b%F{3}|%F{1}%a%F{5}%f' |
|
19 |
+zstyle ':vcs_info:*' formats \ |
|
20 |
+ '%F{5}%f%s%F{5}%F{3}->%F{5}%F{2}%b%F{5}%f' |
|
21 |
+zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' |
|
22 |
+ |
|
23 |
+zstyle ':vcs_info:*' enable git cvs svn |
|
24 |
+ |
|
25 |
+vcs_info_wrapper() { |
|
26 |
+ vcs_info |
|
27 |
+ if [ -n "$vcs_info_msg_0_" ]; then |
|
28 |
+ echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del" |
|
29 |
+ fi |
|
30 |
+} |
|
31 |
+ |
|
32 |
+# indicate whether we're in insert mode |
|
33 |
+function zle-line-init zle-keymap-select { |
|
34 |
+ RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}" |
|
35 |
+ RPS2=$RPS1 |
|
36 |
+ zle reset-prompt |
|
37 |
+} |
|
38 |
+zle -N zle-line-init |
|
39 |
+zle -N zle-keymap-select |
|
40 |
+ |
|
41 |
+export PYTHONSTARTUP=$HOME/Library/Python/2.7/site-packages/sitecustomize.py |
|
42 |
+ |
|
43 |
+PROMPT='--- |
|
44 |
+(%?) %m:%n--%l ${PWD/$HOME/~} `vcs_info_wrapper` `battery_charge` |
|
45 |
+%!:%# ' |
|
46 |
+export PROMPT |
|
47 |
+ |
|
48 |
+HOSTNAME=`hostname -f` |
|
49 |
+PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' |
|
50 |
+ |
|
51 |
+cmdtermtitle() { |
|
52 |
+ cmd_name="${(V)1}" |
|
53 |
+ if [ 'fg' = "${${(z)@}[1]}" ]; then |
|
54 |
+ cmd_name="${(vV)jobtexts}" |
|
55 |
+ fi |
|
56 |
+ |
|
57 |
+ if [[ "${TERM%%-*}"x == "screen"x ]]; then |
|
58 |
+ echo -ne "\033]0;${cmd_name}\007" |
|
59 |
+ else |
|
60 |
+ echo -ne "\033]0; ${cmd_name} : ${USER}@$HOSTNAME\007" |
|
61 |
+ fi |
|
62 |
+} |
|
63 |
+ |
|
64 |
+if [[ $TERM != "linux" && ${TERM%-color} != "eterm" ]]; then |
|
65 |
+ add-zsh-hook preexec cmdtermtitle |
|
66 |
+fi |
|
67 |
+ |
|
68 |
+termtitle() { |
|
69 |
+ npwd=${PWD/#$HOME/\~} |
|
70 |
+ if [[ "${TERM%%-*}"x == "screen"x ]]; then |
|
71 |
+ echo -ne "\033]0;${npwd}\007" |
|
72 |
+ else |
|
73 |
+ echo -ne "\033]0;${USER}@$HOSTNAME: ${npwd}\007" |
|
74 |
+ fi |
|
75 |
+} |
|
76 |
+ |
|
77 |
+if [[ $TERM != "linux" && ${TERM%-color} != "eterm" ]]; then |
|
78 |
+ add-zsh-hook precmd termtitle |
|
79 |
+fi |
|
80 |
+ |
|
81 |
+ "" |
|
82 |
+if battery_charge 2>&1 >/dev/null; then |
|
83 |
+ PROMPT='--- |
|
84 |
+(%?) %m:%n--%l %~ `vcs_info_wrapper` `battery_charge 2>/dev/null` |
|
85 |
+%!:%# ' |
|
86 |
+else |
|
87 |
+ PROMPT=$'---\n$(doing)${$(doing):+\n}(%?) %m:%n--%l %~ `vcs_info_wrapper` `date +"%Y-%m-%d %H:%M:%S"` |
|
88 |
+%!:%# ' |
|
89 |
+fi |
|
90 |
+export PROMPT |
0 | 91 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,31 @@ |
1 |
+PATH="${PATH%%:<<<:*}:${PATH##*:>>>:}" |
|
2 |
+ |
|
3 |
+prepend_exe_path "$HOME/cj-projects/software/bin" |
|
4 |
+prepend_exe_path "$HOME/cj-projects/software/resin/3.1.8-pro/bin" |
|
5 |
+prepend_exe_path "$HOME/pfff/bin" |
|
6 |
+prepend_exe_path "$HOME/Library/Python/2.7/bin" |
|
7 |
+prepend_exe_path "$HOME/go/bin" |
|
8 |
+prepend_exe_path "$HOME/.rvm/bin" |
|
9 |
+prepend_exe_path /Library/Frameworks/Mono.framework/Versions/Current/Commands |
|
10 |
+prepend_exe_path /usr/local/share/dotnet |
|
11 |
+prepend_exe_path /bin |
|
12 |
+prepend_exe_path /usr/bin |
|
13 |
+prepend_exe_path /Developer/usr/bin |
|
14 |
+prepend_exe_path /usr/local/bin |
|
15 |
+prepend_exe_path "$HOME/.cargo/bin" |
|
16 |
+prepend_exe_path /opt/local/bin |
|
17 |
+prepend_exe_path /usr/X11/bin |
|
18 |
+prepend_exe_path "$HOME/vim8/bin" |
|
19 |
+prepend_exe_path "$HOME/.cabal/bin" |
|
20 |
+prepend_exe_path "$HOME/.local/bin" |
|
21 |
+prepend_exe_path /Library/Java/Home/bin |
|
22 |
+prepend_exe_path "$HOME/.nix-profile/bin" |
|
23 |
+prepend_exe_path "$HOME/bin" |
|
24 |
+ |
|
25 |
+prepend_exe_path /sbin |
|
26 |
+prepend_exe_path /usr/sbin |
|
27 |
+prepend_exe_path /usr/local/sbin |
|
28 |
+prepend_exe_path /opt/local/sbin |
|
29 |
+prepend_exe_path "$HOME/.nix-profile/sbin" |
|
30 |
+ |
|
31 |
+PATH="${PATH%:}" |