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

View File

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