|
diff --git a/.shenanigans.sh b/.shenanigans.sh
|
| 1 |
# Magical environment variables. |
1 |
# Magical environment variables. |
| 2 |
NIX_SHELL_PRESERVE_PROMPT=1 |
2 |
export NIX_SHELL_PRESERVE_PROMPT=1 |
| 3 |
TERM=xterm-256color |
3 |
export COLORTERM=truecolor |
| 4 |
VISUAL=vim |
4 |
export TERM=xterm-256color |
| 5 |
EDITOR=vim |
5 |
export VISUAL=vim |
|
|
6 |
export EDITOR=vim |
| 6 |
|
7 |
|
| 7 |
parse_git_branch() { |
8 |
parse_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 |
export 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 |
export 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. |
| 22 |
alias ls='ls --color=none' |
23 |
alias l='ls -lh' |
| 23 |
alias l='ls -lh --color=none' |
24 |
alias ll='ls -lha' |
| 24 |
alias ll='ls -lha --color=none' |
|
|
| 25 |
alias t='tree -L 2' |
25 |
alias t='tree -L 2' |
| 26 |
alias ..='cd ..' |
26 |
alias ..='cd ..' |
| 27 |
alias grep='grep --color=always' |
27 |
alias grep='grep --color=always' |
| ... |
| 40 |
export PATH=$HOME/go/bin:$PATH |
40 |
export PATH=$HOME/go/bin:$PATH |
| 41 |
export PATH=/usr/local/go/bin:$PATH |
41 |
export PATH=/usr/local/go/bin:$PATH |
| 42 |
|
42 |
|
| 43 |
# Language server. |
43 |
# Language servers. |
| 44 |
export PATH=$HOME/.local/bin/luals/bin:$PATH |
44 |
export PATH=$HOME/.local/bin/luals/bin:$PATH |
| 45 |
|
45 |
|
| 46 |
# History and search. Stolen from J. |
46 |
# History and search. Stolen from J. |
| ... |
| 99 |
|
99 |
|
| 100 |
# Return back to original directory |
100 |
# Return back to original directory |
| 101 |
cd $CWD |
101 |
cd $CWD |
| 102 |
} |
|
|
| 103 |
|
|
|
| 104 |
# Simple ticket system based on https://github.com/mitjafelicijan/ticket. |
|
|
| 105 |
export TICKETS=~/Vault/tickets |
|
|
| 106 |
tt() { |
|
|
| 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 |
} |
102 |
} |
| 178 |
|
103 |
|
| 179 |
# Toggles between pulseaudio sinks in round-robin. |
104 |
# Toggles between pulseaudio sinks in round-robin. |
| ... |