Browse Source

Created my own simple task manager in place of t

tags/v0.2.0
Micah Halter 2 years ago
parent
commit
1c68a0fafa
7 changed files with 150 additions and 11 deletions
  1. +0
    -6
      .gitmodules
  2. +74
    -0
      scripts-work/.config/Scripts/tasks.sh
  3. +74
    -0
      scripts/.config/Scripts/tasks.sh
  4. +0
    -1
      t/.t
  5. +0
    -4
      zsh-work/.zsh_aliases
  6. +1
    -0
      zsh-work/.zshrc
  7. +1
    -0
      zsh/.zshrc

+ 0
- 6
.gitmodules View File

@@ -1,6 +0,0 @@
[submodule "zsh/.zprezto"]
path = zsh/.zprezto
url = https://github.com/sorin-ionescu/prezto.git
[submodule "t/.t"]
path = t/.t
url = https://github.com/sjl/t.git

+ 74
- 0
scripts-work/.config/Scripts/tasks.sh View File

@@ -0,0 +1,74 @@
# simple task system
taskfile=$HOME/.tasks
alias tl='if [ -f $taskfile ]; then
count=1
while read -r task; do
echo -e "$count:-- $task"
(( count++ ))
done < $taskfile | column -t -s :
fi'

ta() {
if [ "$1" != "" ]; then
touch $taskfile
echo -e "$@" >> $taskfile
tl
fi
}

td() {
if [ "$1" -le "$(wc -l < $taskfile)" ]; then
sed -i "$1d" "$taskfile"
tl
fi
}

_complete_goto_bash() {
local cur="${COMP_WORDS[$COMP_CWORD]}" prev

if [ "$COMP_CWORD" -eq "1" ]; then
local width=$(bind -v | sed -n 's/^set completion-display-width //p')

if [[ $width -ne 0 ]]; then
# change the readline variable
bind "set completion-display-width 0"

# set up PROMPT_COMMAND to reset itself to its current value
PROMPT_COMMAND="PROMPT_COMMAND=$(printf %q "$PROMPT_COMMAND")"

# set up PROMPT_COMMAND to reset the readline variable
PROMPT_COMMAND+="; bind 'set completion-display-width $width'"
fi

local IFS=$'\n' matches

matches=($(sed = $taskfile|sed 'N;s/\n/:/'|sed '/'"$cur"'[0-9]*/!d' 2>/dev/null))

compopt +o filenames 2>/dev/null
if [ "${#matches[@]}" -eq "1" ]; then
COMPREPLY=("${matches[0]%%$':'*}")
else
for i in "${!matches[@]}"; do
COMPREPLY+=("$(compgen -W "${matches[$i]%%$'\t'*}")")
done
fi
IFS=$'\n' COMPREPLY=($(printf "%s\n" "${COMPREPLY[@]}"|column -t -s :))
fi
}

_complete_pins_zsh() {
if [ ${#words[@]} -eq 2 ]; then
local all_aliases=()
while IFS= read -r line; do
all_aliases+=("$line")
done <<< "$(sed = $taskfile | sed 'N;s/\n/:/' 2>/dev/null)"

_describe -t aliases 'pinned aliases:' all_aliases && return 0
fi
}

if [ -n "${BASH_VERSION}" ]; then
complete -F _complete_goto_bash td
elif [ -n "${ZSH_VERSION}" ]; then
compdef _complete_pins_zsh td
fi

+ 74
- 0
scripts/.config/Scripts/tasks.sh View File

@@ -0,0 +1,74 @@
# simple task system
taskfile=$HOME/.tasks
alias tl='if [ -f $taskfile ]; then
count=1
while read -r task; do
echo -e "$count:-- $task"
(( count++ ))
done < $taskfile | column -t -s :
fi'

ta() {
if [ "$1" != "" ]; then
touch $taskfile
echo -e "$@" >> $taskfile
tl
fi
}

td() {
if [ "$1" -le "$(wc -l < $taskfile)" ]; then
sed -i "$1d" "$taskfile"
tl
fi
}

_complete_goto_bash() {
local cur="${COMP_WORDS[$COMP_CWORD]}" prev

if [ "$COMP_CWORD" -eq "1" ]; then
local width=$(bind -v | sed -n 's/^set completion-display-width //p')

if [[ $width -ne 0 ]]; then
# change the readline variable
bind "set completion-display-width 0"

# set up PROMPT_COMMAND to reset itself to its current value
PROMPT_COMMAND="PROMPT_COMMAND=$(printf %q "$PROMPT_COMMAND")"

# set up PROMPT_COMMAND to reset the readline variable
PROMPT_COMMAND+="; bind 'set completion-display-width $width'"
fi

local IFS=$'\n' matches

matches=($(sed = $taskfile|sed 'N;s/\n/:/'|sed '/'"$cur"'[0-9]*/!d' 2>/dev/null))

compopt +o filenames 2>/dev/null
if [ "${#matches[@]}" -eq "1" ]; then
COMPREPLY=("${matches[0]%%$':'*}")
else
for i in "${!matches[@]}"; do
COMPREPLY+=("$(compgen -W "${matches[$i]%%$'\t'*}")")
done
fi
IFS=$'\n' COMPREPLY=($(printf "%s\n" "${COMPREPLY[@]}"|column -t -s :))
fi
}

_complete_pins_zsh() {
if [ ${#words[@]} -eq 2 ]; then
local all_aliases=()
while IFS= read -r line; do
all_aliases+=("$line")
done <<< "$(sed = $taskfile | sed 'N;s/\n/:/' 2>/dev/null)"

_describe -t aliases 'pinned aliases:' all_aliases && return 0
fi
}

if [ -n "${BASH_VERSION}" ]; then
complete -F _complete_goto_bash td
elif [ -n "${ZSH_VERSION}" ]; then
compdef _complete_pins_zsh td
fi

+ 0
- 1
t/.t

@@ -1 +0,0 @@
Subproject commit 24919826d7dcbcfc6508997e528b44c46b9cb0e0

+ 0
- 4
zsh-work/.zsh_aliases View File

@@ -58,10 +58,6 @@ alias vd='vdirsyncer'
alias vds='vdirsyncer sync'

# various app aliases
taskdir="~/.tasks"
alias t='python ~/.t/t.py --task-dir $taskdir --list tasks'
tf() { python ~/.t/t.py --task-dir $taskdir --list tasks -f $1 && t }
alias te='python ~/.t/t.py --task-dir $taskdir --list tasks -e'
alias nb='newsboat'
alias nf='neofetch'
alias yt="mpsyt"


+ 1
- 0
zsh-work/.zshrc View File

@@ -91,6 +91,7 @@ if [ ! -d ~/.tasks ]; then
fi

[ -f ~/.config/Scripts/pins.sh ] && source ~/.config/Scripts/pins.sh
[ -f ~/.config/Scripts/tasks.sh ] && source ~/.config/Scripts/tasks.sh

export DBSTRING="postgres://postgres:postgres@localhost/postgres?sslmode=disable"



+ 1
- 0
zsh/.zshrc View File

@@ -84,6 +84,7 @@ if [ ! -d ~/.tasks ]; then
fi

[ -f ~/.config/Scripts/pins.sh ] && source ~/.config/Scripts/pins.sh
[ -f ~/.config/Scripts/tasks.sh ] && source ~/.config/Scripts/tasks.sh

(cat ~/.cache/wal/sequences &)



Loading…
Cancel
Save