Merge pull request #2005 from gaelicWizard/plugin-todo

Plugin/todo: cleanup and simplify
pull/2007/head
Noah Gorny 2022-01-07 08:40:52 +02:00 committed by GitHub
commit 48a1ff7fb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 24 deletions

View File

@ -110,6 +110,7 @@ plugins/available/pyenv.plugin.bash
plugins/available/rbenv.plugin.bash
plugins/available/ruby.plugin.bash
plugins/available/textmate.plugin.bash
plugins/available/todo.plugin.bash
plugins/available/xterm.plugin.bash
plugins/available/zoxide.plugin.bash

View File

@ -67,7 +67,7 @@ function passgen() {
# Create alias pass to passgen when pass isn't installed or
# BASH_IT_LEGACY_PASS is true.
if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" = true ]]; then
if ! _command_exists pass || [[ "${BASH_IT_LEGACY_PASS:-}" == true ]]; then
alias pass=passgen
fi
@ -120,20 +120,26 @@ function usage() {
esac
}
# shellcheck disable=SC2144 # the glob matches only one file
if [[ ! -e "${BASH_IT?}/plugins/enabled/todo.plugin.bash" && ! -e "${BASH_IT?}/plugins/enabled"/*"${BASH_IT_LOAD_PRIORITY_SEPARATOR-}todo.plugin.bash" ]]; then
# if user has installed todo plugin, skip this...
function t() {
about 'one thing todo'
about 'todo.sh if available, otherwise one thing todo'
param 'if not set, display todo item'
param '1: todo text'
if [[ "$*" == "" ]]; then
cat ~/.t
local todotxt="${XDG_STATE_HOME:-~/.local/state}/bash_it/todo.txt"
if _bash-it-component-item-is-enabled plugin todo; then
todo.sh "$@"
return
elif [[ ! -f "${todotxt}" && -f ~/.t ]]; then
mv -vn ~/.t "${todotxt}" # Verbose, so the user knows. Don't overwrite, just in case.
fi
if [[ "$#" -eq 0 ]]; then
cat "${todotxt}"
else
echo "$*" > ~/.t
echo "$@" >| "${todotxt}"
fi
}
fi
if _command_exists mkisofs; then
function mkiso() {

View File

@ -1,12 +1,6 @@
#!/bin/bash
cite about-plugin
# shellcheck shell=bash
about-plugin 'Todo.txt integration'
# you may override any of the exported variables below in your .bash_profile
if [ -z "$TODOTXT_DEFAULT_ACTION" ]; then
# typing 't' by itself will list current todos
export TODOTXT_DEFAULT_ACTION=ls
fi
alias t='todo.sh'
: "${TODOTXT_DEFAULT_ACTION:=ls}"
export TODOTXT_DEFAULT_ACTION