blob: e6a210a5cbbf3d03cd36c51cd2602656ae62273d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
# Software list.
# cifs-utils tree hstr s3cmd xclip mc gnupg ripgrep jq xmlstarlet htop nvtop tmux vim ctags picom scrot
# Magical environment variables.
NIX_SHELL_PRESERVE_PROMPT=1
TERM=xterm-256color
VISUAL=vim
EDITOR=vim
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
is_inside_nix_shell() {
nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)"
if [[ -n "$nix_shell_name" ]]; then
echo " \e[0;36m(nix-shell)\e[0m"
fi
}
# Better prompt.
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$ "
# General aliases.
alias ls='ls --color=none'
alias l='ls -lh --color=none'
alias ll='ls -lha --color=none'
alias t='tree -L 2'
alias ..='cd ..'
alias grep='grep --color=always'
alias less='less -R'
alias tmux='tmux -u'
alias vi='vim'
alias newsraft='newsraft -f ~/.dotfiles/rssfeeds'
alias server='python3 -m http.server 6969'
# Custom folder jump commands.
alias p='cd ~/Vault/projects'
alias j='cd ~/Junk/current'
alias d='cd ~/Downloads'
# Additional path settings.
export PATH=$HOME/Applications:$PATH
export PATH=$HOME/go/bin:$PATH
export PATH=/usr/local/go/bin:$PATH
# Other paths.
export PATH=$HOME/.local/bin/odin-linux-amd64-dev-2024-1:$PATH
# History and search. Stolen from J.
HISTCONTROL=ignoreboth
shopt -s histappend
export HISTSIZE=
export HISTFILESIZE=
export HISTFILE=~/.bash_history_infinite
PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
export HSTR_CONFIG=hicolor
if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi
# Backup to NAS function. Much wow!
backup() {
CWD=$(pwd)
VHOME=/home/$USER/Vault
ME=$(whoami)@$(hostname)
mkdir -p $VHOME/dotfiles
cd $VHOME/dotfiles
# Make a copy of certain files.
cp /home/$USER/.shenanigans.sh shenanigans.sh
cp /home/$USER/.bash_history_infinite bash_history_infinite
cp /home/$USER/.gitconfig gitconfig
cp -Rf /home/$USER/.ssh/ ./
cp -Rf /home/$USER/.aws/ ./
find /home/$USER/Videos -type f -name "*.webm" -exec cp -n {} $VHOME/videos/ \;
find /home/$USER/Pictures -type f -name "*.png" -exec cp -n {} $VHOME/pictures/ \;
# Sync with NAS.
rsync -azv \
--exclude '.venv/' \
--exclude '.git/' \
--exclude '.import/' \
--exclude '.godot/' \
--exclude '.zig-cache/' \
--exclude 'node_modules/' \
--exclude 'digg-v5/' \
--delete \
$VHOME/ /media/Void/Backup/$ME/
# Add to log file.
echo `date +"%D %T"` >> ~/.vault.log
# Return back to original directory
cd $CWD
}
export TICKETS=~/Vault/tickets
tt() { # https://github.com/mitjafelicijan/ticket
if [ "$(uname -s)" != "Linux" ]; then
printf "Currently only Linux is supported.\n"
return 1
fi
if [ -z "$TICKETS" ]; then
TICKETS="$HOME/tickets"
fi
mkdir -p $TICKETS
# Display open tickets if no argument provided.
if [ -z "$1" ]; then
echo "`tt -o`"
return 0
fi
case $1 in
-n|-new)
# ticket_id=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 10 | head -n 1)
ticket_id=$(echo -n "$(date)" | md5sum | cut -c 9-20)
ticket_file=$TICKETS/$ticket_id
printf "id: %s\n" $ticket_id > $ticket_file
printf "responsible: %s\n" `whoami`@`hostname` >> $ticket_file
printf "created: %s\n" "`date`" >> $ticket_file
printf "status: open\n" >> $ticket_file
printf "title: ?\n" >> $ticket_file
printf "====\n" >> $ticket_file
printf "Describe your problem here\n" >> $ticket_file
$EDITOR $ticket_file
;;
-o|-open)
printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title"
printf "%0.s-" {1..100}
printf "\n"
grep --color=never -l 'status: open' $TICKETS/* | while read file; do
id=$(head -n 1 "$file" | tail -n 1 | awk '{ print $2 }')
title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}')
cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}')
cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S")
printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title"
done
;;
-c|-closed)
printf "%-14s %-21s %s\n" "Ticket ID" "Created at" "Title"
printf "%0.s-" {1..100}
printf "\n"
grep --color=never -l 'status: closed' $TICKETS/* | while read file; do
id=$(head -n 1 "$file" | tail -n 1 | awk '{ print $2 }')
title=$(head -n 5 "$file" | tail -n 1 | awk '{$1=""; print $0}')
cdate=$(head -n 3 "$file" | tail -n 1 | awk '{$1=""; print $0}')
cdate_fmt=$(date -d "$cdate" "+%Y-%m-%d %H:%M:%S")
printf "%-14s %-20s %.66s\n" "$id" "$cdate_fmt" "$title"
done
;;
-h|-help)
printf "Usage: ticket [option]\n"
printf " -n, -new creates a new ticket\n"
printf " -o, -open lists open tickets\n"
printf " -c, -closed lists closed tickets\n"
printf " -h, -help shows this help\n"
;;
*)
if [ -e "$TICKETS/$1" ] && [ -f "$TICKETS/$1" ]; then
$EDITOR "$TICKETS/$1"
else
printf "Ticket not found: $TICKETS/$1\n"
fi
;;
esac
}
|