Browse Source

Created my own simple task manager in place of t

tags/v0.2.0
Micah Halter 1 year 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 @@
1
-[submodule "zsh/.zprezto"]
2
-	path = zsh/.zprezto
3
-	url = https://github.com/sorin-ionescu/prezto.git
4
-[submodule "t/.t"]
5
-	path = t/.t
6
-	url = https://github.com/sjl/t.git

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

@@ -0,0 +1,74 @@
1
+# simple task system
2
+taskfile=$HOME/.tasks
3
+alias tl='if [ -f $taskfile ]; then
4
+            count=1
5
+            while read -r task; do
6
+              echo -e "$count:-- $task"
7
+              (( count++ ))
8
+            done < $taskfile | column -t -s :
9
+          fi'
10
+
11
+ta() {
12
+  if [ "$1" != "" ]; then
13
+    touch $taskfile
14
+    echo -e "$@" >> $taskfile
15
+    tl
16
+  fi
17
+}
18
+
19
+td() {
20
+  if [ "$1" -le "$(wc -l < $taskfile)" ]; then
21
+    sed -i "$1d" "$taskfile"
22
+    tl
23
+  fi
24
+}
25
+
26
+_complete_goto_bash() {
27
+  local cur="${COMP_WORDS[$COMP_CWORD]}" prev
28
+
29
+  if [ "$COMP_CWORD" -eq "1" ]; then
30
+    local width=$(bind -v | sed -n 's/^set completion-display-width //p')
31
+
32
+    if [[ $width -ne 0 ]]; then
33
+        # change the readline variable
34
+        bind "set completion-display-width 0"
35
+
36
+        # set up PROMPT_COMMAND to reset itself to its current value
37
+        PROMPT_COMMAND="PROMPT_COMMAND=$(printf %q "$PROMPT_COMMAND")"
38
+
39
+        # set up PROMPT_COMMAND to reset the readline variable
40
+        PROMPT_COMMAND+="; bind 'set completion-display-width $width'"
41
+    fi
42
+
43
+    local IFS=$'\n' matches
44
+
45
+    matches=($(sed = $taskfile|sed 'N;s/\n/:/'|sed '/'"$cur"'[0-9]*/!d' 2>/dev/null))
46
+
47
+    compopt +o filenames 2>/dev/null
48
+    if [ "${#matches[@]}" -eq "1" ]; then
49
+      COMPREPLY=("${matches[0]%%$':'*}")
50
+    else
51
+      for i in "${!matches[@]}"; do
52
+        COMPREPLY+=("$(compgen -W "${matches[$i]%%$'\t'*}")")
53
+      done
54
+    fi
55
+    IFS=$'\n' COMPREPLY=($(printf "%s\n" "${COMPREPLY[@]}"|column -t -s :))
56
+  fi
57
+}
58
+
59
+_complete_pins_zsh() {
60
+  if [ ${#words[@]} -eq 2 ]; then
61
+    local all_aliases=()
62
+    while IFS= read -r line; do
63
+      all_aliases+=("$line")
64
+    done <<< "$(sed = $taskfile | sed 'N;s/\n/:/' 2>/dev/null)"
65
+
66
+    _describe -t aliases 'pinned aliases:' all_aliases && return 0
67
+  fi
68
+}
69
+
70
+if [ -n "${BASH_VERSION}" ]; then
71
+  complete -F _complete_goto_bash td
72
+elif [ -n "${ZSH_VERSION}" ]; then
73
+  compdef _complete_pins_zsh td
74
+fi

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

@@ -0,0 +1,74 @@
1
+# simple task system
2
+taskfile=$HOME/.tasks
3
+alias tl='if [ -f $taskfile ]; then
4
+            count=1
5
+            while read -r task; do
6
+              echo -e "$count:-- $task"
7
+              (( count++ ))
8
+            done < $taskfile | column -t -s :
9
+          fi'
10
+
11
+ta() {
12
+  if [ "$1" != "" ]; then
13
+    touch $taskfile
14
+    echo -e "$@" >> $taskfile
15
+    tl
16
+  fi
17
+}
18
+
19
+td() {
20
+  if [ "$1" -le "$(wc -l < $taskfile)" ]; then
21
+    sed -i "$1d" "$taskfile"
22
+    tl
23
+  fi
24
+}
25
+
26
+_complete_goto_bash() {
27
+  local cur="${COMP_WORDS[$COMP_CWORD]}" prev
28
+
29
+  if [ "$COMP_CWORD" -eq "1" ]; then
30
+    local width=$(bind -v | sed -n 's/^set completion-display-width //p')
31
+
32
+    if [[ $width -ne 0 ]]; then
33
+        # change the readline variable
34
+        bind "set completion-display-width 0"
35
+
36
+        # set up PROMPT_COMMAND to reset itself to its current value
37
+        PROMPT_COMMAND="PROMPT_COMMAND=$(printf %q "$PROMPT_COMMAND")"
38
+
39
+        # set up PROMPT_COMMAND to reset the readline variable
40
+        PROMPT_COMMAND+="; bind 'set completion-display-width $width'"
41
+    fi
42
+
43
+    local IFS=$'\n' matches
44
+
45
+    matches=($(sed = $taskfile|sed 'N;s/\n/:/'|sed '/'"$cur"'[0-9]*/!d' 2>/dev/null))
46
+
47
+    compopt +o filenames 2>/dev/null
48
+    if [ "${#matches[@]}" -eq "1" ]; then
49
+      COMPREPLY=("${matches[0]%%$':'*}")
50
+    else
51
+      for i in "${!matches[@]}"; do
52
+        COMPREPLY+=("$(compgen -W "${matches[$i]%%$'\t'*}")")
53
+      done
54
+    fi
55
+    IFS=$'\n' COMPREPLY=($(printf "%s\n" "${COMPREPLY[@]}"|column -t -s :))
56
+  fi
57
+}
58
+
59
+_complete_pins_zsh() {
60
+  if [ ${#words[@]} -eq 2 ]; then
61
+    local all_aliases=()
62
+    while IFS= read -r line; do
63
+      all_aliases+=("$line")
64
+    done <<< "$(sed = $taskfile | sed 'N;s/\n/:/' 2>/dev/null)"
65
+
66
+    _describe -t aliases 'pinned aliases:' all_aliases && return 0
67
+  fi
68
+}
69
+
70
+if [ -n "${BASH_VERSION}" ]; then
71
+  complete -F _complete_goto_bash td
72
+elif [ -n "${ZSH_VERSION}" ]; then
73
+  compdef _complete_pins_zsh td
74
+fi

+ 0
- 1
t/.t

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

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

@@ -58,10 +58,6 @@ alias vd='vdirsyncer'
58 58
 alias vds='vdirsyncer sync'
59 59
 
60 60
 # various app aliases
61
-taskdir="~/.tasks"
62
-alias t='python ~/.t/t.py --task-dir $taskdir --list tasks'
63
-tf() { python ~/.t/t.py --task-dir $taskdir --list tasks -f $1 && t }
64
-alias te='python ~/.t/t.py --task-dir $taskdir --list tasks -e'
65 61
 alias nb='newsboat'
66 62
 alias nf='neofetch'
67 63
 alias yt="mpsyt"

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

@@ -91,6 +91,7 @@ if [ ! -d ~/.tasks ]; then
91 91
 fi
92 92
 
93 93
 [ -f ~/.config/Scripts/pins.sh ] && source ~/.config/Scripts/pins.sh
94
+[ -f ~/.config/Scripts/tasks.sh ] && source ~/.config/Scripts/tasks.sh
94 95
 
95 96
 export DBSTRING="postgres://postgres:postgres@localhost/postgres?sslmode=disable"
96 97
 

+ 1
- 0
zsh/.zshrc View File

@@ -84,6 +84,7 @@ if [ ! -d ~/.tasks ]; then
84 84
 fi
85 85
 
86 86
 [ -f ~/.config/Scripts/pins.sh ] && source ~/.config/Scripts/pins.sh
87
+[ -f ~/.config/Scripts/tasks.sh ] && source ~/.config/Scripts/tasks.sh
87 88
 
88 89
 (cat ~/.cache/wal/sequences &)
89 90
 

Loading…
Cancel
Save