aboutsummaryrefslogtreecommitdiff
path: root/.shenanigans.sh
diff options
context:
space:
mode:
authorMitja Felicijan <mitja.felicijan@gmail.com>2024-11-13 23:37:29 +0100
committerMitja Felicijan <mitja.felicijan@gmail.com>2024-11-13 23:37:29 +0100
commit628a44fcc62c1e3c52d559efabb2aee32f148b53 (patch)
tree8bcc026bc8bc58929fb56451fb65b0a3644617a7 /.shenanigans.sh
parente97e9fd6930932608f30fb2fd3d6aeb8568c3e74 (diff)
downloaddotfiles-628a44fcc62c1e3c52d559efabb2aee32f148b53.tar.gz
Update
Diffstat (limited to '.shenanigans.sh')
-rwxr-xr-x.shenanigans.sh91
1 files changed, 8 insertions, 83 deletions
diff --git a/.shenanigans.sh b/.shenanigans.sh
index 9a10f57..aa26e23 100755
--- a/.shenanigans.sh
+++ b/.shenanigans.sh
@@ -1,8 +1,9 @@
1# Magical environment variables. 1# Magical environment variables.
2NIX_SHELL_PRESERVE_PROMPT=1 2export NIX_SHELL_PRESERVE_PROMPT=1
3TERM=xterm-256color 3export COLORTERM=truecolor
4VISUAL=vim 4export TERM=xterm-256color
5EDITOR=vim 5export VISUAL=vim
6export EDITOR=vim
6 7
7parse_git_branch() { 8parse_git_branch() {
8 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' 9 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
@@ -19,9 +20,8 @@ is_inside_nix_shell() {
19export PS1="[\033[38;5;166m\]\u@\h\[$(tput sgr0)\]]$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ " 20export PS1="[\033[38;5;166m\]\u@\h\[$(tput sgr0)\]]$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ "
20 21
21# General aliases. 22# General aliases.
22alias ls='ls --color=none' 23alias l='ls -lh'
23alias l='ls -lh --color=none' 24alias ll='ls -lha'
24alias ll='ls -lha --color=none'
25alias t='tree -L 2' 25alias t='tree -L 2'
26alias ..='cd ..' 26alias ..='cd ..'
27alias grep='grep --color=always' 27alias grep='grep --color=always'
@@ -40,7 +40,7 @@ export PATH=$HOME/Applications:$PATH
40export PATH=$HOME/go/bin:$PATH 40export PATH=$HOME/go/bin:$PATH
41export PATH=/usr/local/go/bin:$PATH 41export PATH=/usr/local/go/bin:$PATH
42 42
43# Language server. 43# Language servers.
44export PATH=$HOME/.local/bin/luals/bin:$PATH 44export PATH=$HOME/.local/bin/luals/bin:$PATH
45 45
46# History and search. Stolen from J. 46# History and search. Stolen from J.
@@ -101,81 +101,6 @@ backup() {
101 cd $CWD 101 cd $CWD
102} 102}
103 103
104# Simple ticket system based on https://github.com/mitjafelicijan/ticket.
105export TICKETS=~/Vault/tickets
106tt() {
107 if [ "$(uname -s)" != "Linux" ]; then
108 printf "Currently only Linux is supported.\n"
109 return 1
110 fi
111
112 if [ -z "$TICKETS" ]; then
113 TICKETS="$HOME/tickets"
114 fi
115
116 mkdir -p $TICKETS
117
118 # Display open tickets if no argument provided.
119 if [ -z "$1" ]; then
120 echo "`tt -o`"
121 return 0
122 fi
123
124 case $1 in
125 -n|-new)
126 # ticket_id=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 10 | head -n 1)
127 ticket_id=$(echo -n "$(date)" | md5sum | cut -c 9-20)
128 ticket_file=$TICKETS/$ticket_id
129 printf "id: %s\n" $ticket_id > $ticket_file
130 printf "responsible: %s\n" `whoami`@`hostname` >> $ticket_file
131 printf "created: %s\n" "`date`" >> $ticket_file
132 printf "status: open\n" >> $ticket_file
133 printf "title: ?\n" >> $ticket_file
134 printf "====\n" >> $ticket_file
135 printf "Description...\n" >> $ticket_file
136 $EDITOR $ticket_file
137 ;;
138 -o|-open)
139 printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title"
140 printf "%0.s-" {1..100}
141 printf "\n"
142 grep --color=never -l 'status: open' $TICKETS/* | while read file; do
143 id=$(head -n 1 "$file" | tail -n 1 | awk '{ print $2 }')
144 title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}')
145 cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}')
146 cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S")
147 printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title"
148 done
149 ;;
150 -c|-closed)
151 printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title"
152 printf "%0.s-" {1..100}
153 printf "\n"
154 grep --color=never -l 'status: closed' $TICKETS/* | while read file; do
155 id=$(head -n 1 "$file" | tail -n 1 | awk '{ print $2 }')
156 title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}')
157 cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}')
158 cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S")
159 printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title"
160 done
161 ;;
162 -h|-help)
163 printf "Usage: ticket [option]\n"
164 printf " -n, -new creates a new ticket\n"
165 printf " -o, -open lists open tickets\n"
166 printf " -c, -closed lists closed tickets\n"
167 printf " -h, -help shows this help\n"
168 ;;
169 *)
170 if [ -e "$TICKETS/$1" ] && [ -f "$TICKETS/$1" ]; then
171 $EDITOR "$TICKETS/$1"
172 else
173 printf "Ticket not found: $TICKETS/$1\n"
174 fi
175 ;;
176 esac
177}
178
179# Toggles between pulseaudio sinks in round-robin. 104# Toggles between pulseaudio sinks in round-robin.
180togglesink() { 105togglesink() {
181 sinks=($(pactl list short sinks | awk '{print $2}')) 106 sinks=($(pactl list short sinks | awk '{print $2}'))