diff options
| author | Paul Buetow <paul@buetow.org> | 2025-04-20 12:54:32 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-04-20 12:54:32 +0300 |
| commit | 00f54efd1b3c57133399876547a03829e311d5fc (patch) | |
| tree | 76bde89ebfcdaece2f21e7ead4d96e68f41252f0 | |
| parent | 43ebf1f7050b620c4a2706da7473fd45570c1b69 (diff) | |
add worktime
| -rw-r--r-- | dotfiles/fish/conf.d/config.fish | 3 | ||||
| -rw-r--r-- | dotfiles/fish/conf.d/dotfiles.fish | 3 | ||||
| -rw-r--r-- | dotfiles/fish/conf.d/tmputils.fish | 55 | ||||
| -rw-r--r-- | dotfiles/fish/conf.d/worktime.fish | 113 |
4 files changed, 172 insertions, 2 deletions
diff --git a/dotfiles/fish/conf.d/config.fish b/dotfiles/fish/conf.d/config.fish index 459b8c5..1d4f292 100644 --- a/dotfiles/fish/conf.d/config.fish +++ b/dotfiles/fish/conf.d/config.fish @@ -3,6 +3,9 @@ fish_vi_key_bindings set -g EDITOR hx set -g VISUAL hx +# Add paths to PATH +set -U fish_user_paths ~/bin ~/go/bin ~/.cargo/bin $fish_user_paths + # Git stuff abbr -a gl 'git log --pretty=oneline --graph --decorate --all' abbr -a gp 'begin; git commit -a; and git pull; and git push; end' diff --git a/dotfiles/fish/conf.d/dotfiles.fish b/dotfiles/fish/conf.d/dotfiles.fish index 2f11beb..1c89c7e 100644 --- a/dotfiles/fish/conf.d/dotfiles.fish +++ b/dotfiles/fish/conf.d/dotfiles.fish @@ -36,8 +36,7 @@ function dotfiles::rexify end function dotfiles::random::edit - $EDITOR (find . -type f | sort -R | head -n 1) - cd - + $EDITOR (find $DOTFILES_DIR -type f -not -path '*/.git/*' | shuf -n 1) end abbr -a .u 'dotfiles::update' diff --git a/dotfiles/fish/conf.d/tmputils.fish b/dotfiles/fish/conf.d/tmputils.fish new file mode 100644 index 0000000..0cfa5b7 --- /dev/null +++ b/dotfiles/fish/conf.d/tmputils.fish @@ -0,0 +1,55 @@ + +set -gx TMPUTILS_DIR ~/data/tmp +set -gx TMPUTILS_TMPFILE ~/.tmpfile + +function tmpls + if not test -d $TMPUTILS_DIR + return + end + ls $TMPUTILS_DIR +end + +function tmptee + set -l name $argv[1] + if test -z "$name" + set name (date +%s) + else + set -e argv[1] + end + set -l file "$TMPUTILS_DIR/$name" + if not test -d $TMPUTILS_DIR + mkdir -p $TMPUTILS_DIR + end + tee $argv $file + echo $file >$TMPUTILS_TMPFILE +end + +function tmpcat + set -l name $argv[1] + if test -z "$name" + cat (tmpfile) + return + end + cat "$TMPUTILS_DIR/$name" +end + +function tmpedit + set -l name $argv[1] + if test -z "$name" + $EDITOR (tmpfile) + return + end + $EDITOR "$TMPUTILS_DIR/$name" +end + +function tmpgrep + set -l name $argv[1] + set -e argv[1] + tmcpat $name | grep $argv +end + +function tmpfile + cat $TMPUTILS_TMPFILE +end + +abbr -a cdtmp "cd $TMPUTILS_DIR" diff --git a/dotfiles/fish/conf.d/worktime.fish b/dotfiles/fish/conf.d/worktime.fish new file mode 100644 index 0000000..45ed787 --- /dev/null +++ b/dotfiles/fish/conf.d/worktime.fish @@ -0,0 +1,113 @@ +set -gx WORKTIME_DIR ~/git/worktime + +if test (uname) = Darwin -a ! -f ~/.wtloggedin + echo "Warn: Not logged in, run wtlogin" +end + +function worktime + ruby $WORKTIME_DIR/worktime.rb $argv +end + +function worktime::wisdom_reminder + if test -f $WORKTIME_DIR/work-wisdoms.md + sed -n '/^\* / { s/\* //; p; }' $WORKTIME_DIR/work-wisdoms.md | sort -R | head -n 1 + end +end + +function worktime::report + if test -f ~/.wtloggedin + if test -f ~/.wtmaster + worktime --report | tee $WORKTIME_DIR/report.txt + else + worktime --report + end + worktime::wisdom_reminder + end +end + +function worktime::add + set -l seconds $argv[1] + set -l what $argv[2] + set -l descr $argv[3] + set -l epoch (date +%s) + + if test -z "$what" + set what work + end + + if test -z "$descr" + worktime --add $seconds --epoch $epoch --what $what + else + worktime --add $seconds --epoch $epoch --what $what --descr "$descr" + end + + worktime::report +end + +function worktime::log + set -l seconds $argv[1] + set -l what $argv[2] + set -l epoch (date +%s) + + if test -z "$what" + set what work + end + + worktime --log --epoch $epoch --what $what + worktime::report +end + +function worktime::login + set -l what $argv[1] + if test -z "$what" + set what work + end + touch ~/.wtloggedin + worktime --login --what $what + worktime::wisdom_reminder +end + +function worktime::logout + set -l what $argv[1] + + if test -z "$what" + set what work + end + + if test -f ~/.wtloggedin + rm ~/.wtloggedin + end + + worktime --logout --what $what + worktime::report +end + +function worktime::status + worktime::report + + if test -f ~/.wtloggedin + echo "You are logged in" + set -l num_worklog (ls $WORKTIME_DIR | grep wl- | wc -l) + if test $num_worklog -gt 0 + echo "$num_worklog entries in the worklog" + end + else + echo "You are not logged in" + end +end + +abbr -a cdworktime "cd $WORKTIME_DIR" +abbr -a wt worktime +abbr -a wtedit 'worktime --edit' +abbr -a wtreport 'worktime --report' +abbr -a wtadd 'worktime::add' +abbr -a wtlog 'worktime::log' +abbr -a wtlogin 'worktime::login' +abbr -a wtlogout 'worktime::logout' +abbr -a wtstatus 'worktime::status' +abbr -a wtf 'worktime --report' +abbr -a random_exercise "sort -R $WORKTIME_DIR/exercises.md | head -n 1" +abbr -a random_exercises "sort -R $WORKTIME_DIR/exercises.md | head -n 10" +abbr -a ql 'task add +personal' +abbr -a pl 'task add +personal' +abbr -a wl 'task add +work' |
