ALT Linux Sisyphus discussions
 help / color / mirror / Atom feed
* [sisyphus] ztodo: command-line pwd-based todo list manager for zsh users
@ 2009-07-02 14:23 Alexey I. Froloff
  2009-07-02 15:14 ` Afanasov Dmitry
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Alexey I. Froloff @ 2009-07-02 14:23 UTC (permalink / raw)
  To: ALT Linux Sisyphus discussion list


[-- Attachment #1.1: Type: text/plain, Size: 1419 bytes --]

Сначала расскажу зачем я это сделал.

Собираю Ruby 1.9.1.  Процесс этот небыстрый, происходит в N
приёмов.  Сначала убираются анметы и пакет ruby генерит несколько
(десятков) compat пакетов.  На втором шаге compat пакеты
убираются.  Попутно находятся мелкие недоделки, которые в данный
момент большого рояля не играют, но их было бы неплохо устранить.
Поскольку после пакета ruby идёт длинная простыня других пакетов,
то при каких-то изменениях в пакете ruby надо пересобрать и эту
простыню, поэтому несущественные изменения откладываются
"напотом".

Естественно, я не могу всего запомнить.  Держать TODO в каких-то
файликах и периодически туда заглядывать мне лень.  Значит
напоминалка должна орать когда я захожу в git репозитарий ruby.

Кладём приаттаченый файлик в $fpath, в ~/zshrc добавляем:

autoload -Uz ztodo
chpwd() { ztodo }

Usage:

ztodo
  Показать summary.
ztodo add текст
  Добавить entry.
ztodo list
  Показать список.
ztodo del номер
  Удалить entry.
ztodo clear
  Очистить список.

Работает со списком для текущего каталога.  Сам список хранится в
файле ~/.ztodolist, никакого мусора в других каталогах!

Ну и для наглядности скриншот напоминания:

raorn@centaurus:pts/8 ~ $ cd src 
You have 3 things to do here.
raorn@centaurus:pts/8 ~/src $ ztodo list
 1: Collect underpants
 2: ?
 3: PROFIT!
raorn@centaurus:pts/8 ~/src $ 

-- 
Regards,
Sir Raorn.

[-- Attachment #1.2: ztodo --]
[-- Type: text/plain, Size: 1395 bytes --]

# vim: set ft=zsh et sw=2 sts=2:

emulate -L zsh
setopt no_sh_word_split null_glob no_ksh_arrays
typeset -gHA __ztodolist
typeset -gH __ztodolaswrite
local cachefile short_format list_format
local tmp needupdate=0
local -a todos

zstyle -s ':ztodo:*' cache-file cachefile ||
  cachefile="~/.ztodolist"
zstyle -s ':ztodo:*' short-format short_format ||
  short_format="You have %n thing%1(n..s) to do here."
zstyle -s ':ztodo:*' list-format list_format ||
  list_format="%-2n: %e"

tmp=(${~tmp::=$cachefile(ms-$(( ${(%)tmp::="%D{%s}"} - ${__ztodolaswrite:-0} )))})
(( $#tmp )) &&
  . ${~cachefile}

todos=( ${(ps:\0:)__ztodolist[$PWD]} )

if (( $# )); then
  case "$1" in
    (add)
      shift
      todos=( $todos "$*" )
      needupdate=1
      ;;
    (del)
      shift
      todos[$1]=()
      needupdate=1
      ;;
    (clear)
      shift
      todos=()
      needupdate=1
      ;;
    (list)
      shift
      local i
      for (( i = 1; i <= $#todos; i++ )); do
        zformat -f tmp $list_format n:$i e:"$todos[$i]"
        print -P "$tmp"
      done
      ;;
  esac
else
  if [[ $#todos -gt 0 ]]; then
    zformat -f tmp $short_format n:$#todos
    print -P "$tmp"
  fi
fi

(( $#todos )) &&
  __ztodolist[$PWD]=${(pj:\0:)todos} ||
  unset "__ztodolist[$PWD]"
(( needupdate )) &&
  print -r "__ztodolist=( ${(kv@qq)^^__ztodolist} )" > ${~cachefile}
__ztodolaswrite="${(%)tmp::="%D{%s}"}"

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-11-16 17:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-02 14:23 [sisyphus] ztodo: command-line pwd-based todo list manager for zsh users Alexey I. Froloff
2009-07-02 15:14 ` Afanasov Dmitry
2009-07-02 15:21 ` Afanasov Dmitry
2009-07-03  4:28 ` [sisyphus] [JT] " Ildar Mulyukov
2009-07-03  8:15   ` Alexey Tourbin
2009-07-06 22:45 ` [sisyphus] " Денис Смирнов
2009-11-16 17:11 ` Slava Semushin

ALT Linux Sisyphus discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/sisyphus/0 sisyphus/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 sisyphus sisyphus/ http://lore.altlinux.org/sisyphus \
		sisyphus@altlinux.ru sisyphus@altlinux.org sisyphus@lists.altlinux.org sisyphus@lists.altlinux.ru sisyphus@lists.altlinux.com sisyphus@linuxteam.iplabs.ru sisyphus@list.linux-os.ru
	public-inbox-index sisyphus

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.sisyphus


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git