diff options
| -rwxr-xr-x | shenanigans.sh | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/shenanigans.sh b/shenanigans.sh index ce71021..e6a210a 100755 --- a/shenanigans.sh +++ b/shenanigans.sh | |||
| @@ -119,7 +119,8 @@ tt() { # https://github.com/mitjafelicijan/ticket | |||
| 119 | 119 | ||
| 120 | case $1 in | 120 | case $1 in |
| 121 | -n|-new) | 121 | -n|-new) |
| 122 | ticket_id=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 10 | head -n 1) | 122 | # ticket_id=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 10 | head -n 1) |
| 123 | ticket_id=$(echo -n "$(date)" | md5sum | cut -c 9-20) | ||
| 123 | ticket_file=$TICKETS/$ticket_id | 124 | ticket_file=$TICKETS/$ticket_id |
| 124 | printf "id: %s\n" $ticket_id > $ticket_file | 125 | printf "id: %s\n" $ticket_id > $ticket_file |
| 125 | printf "responsible: %s\n" `whoami`@`hostname` >> $ticket_file | 126 | printf "responsible: %s\n" `whoami`@`hostname` >> $ticket_file |
| @@ -131,7 +132,7 @@ tt() { # https://github.com/mitjafelicijan/ticket | |||
| 131 | $EDITOR $ticket_file | 132 | $EDITOR $ticket_file |
| 132 | ;; | 133 | ;; |
| 133 | -o|-open) | 134 | -o|-open) |
| 134 | printf "%-12s %-21s %s\n" "Ticket ID" "Created at" "Title" | 135 | printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title" |
| 135 | printf "%0.s-" {1..100} | 136 | printf "%0.s-" {1..100} |
| 136 | printf "\n" | 137 | printf "\n" |
| 137 | grep --color=never -l 'status: open' $TICKETS/* | while read file; do | 138 | grep --color=never -l 'status: open' $TICKETS/* | while read file; do |
| @@ -139,11 +140,11 @@ tt() { # https://github.com/mitjafelicijan/ticket | |||
| 139 | title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}') | 140 | title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
| 140 | cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}') | 141 | cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
| 141 | cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S") | 142 | cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S") |
| 142 | printf "%-12s %-20s %.66s\n" "$id" "$cdate_fmt" "$title" | 143 | printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title" |
| 143 | done | 144 | done |
| 144 | ;; | 145 | ;; |
| 145 | -c|-closed) | 146 | -c|-closed) |
| 146 | printf "%-12s %-21s %s\n" "Ticket ID" "Created at" "Title" | 147 | printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title" |
| 147 | printf "%0.s-" {1..100} | 148 | printf "%0.s-" {1..100} |
| 148 | printf "\n" | 149 | printf "\n" |
| 149 | grep --color=never -l 'status: closed' $TICKETS/* | while read file; do | 150 | grep --color=never -l 'status: closed' $TICKETS/* | while read file; do |
| @@ -151,7 +152,7 @@ tt() { # https://github.com/mitjafelicijan/ticket | |||
| 151 | title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}') | 152 | title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
| 152 | cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}') | 153 | cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}') |
| 153 | cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S") | 154 | cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S") |
| 154 | printf "%-12s %-20s %.66s\n" "$id" "$cdate_fmt" "$title" | 155 | printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title" |
| 155 | done | 156 | done |
| 156 | ;; | 157 | ;; |
| 157 | -h|-help) | 158 | -h|-help) |
