Skip to content

Commit 20eed8b

Browse files
committed
UPdate 11/05/2025
1 parent 697f89e commit 20eed8b

9 files changed

Lines changed: 155 additions & 11 deletions

File tree

.bashrc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export PGDATA="/usr/local/var/postgres"
2828
export GOPATH=$HOME/go
2929
export MANPAGER="/bin/sh -c \"col -b | nvim -c 'set ft=man ts=8 nomod nolist nonu noma' -\""
3030
export EDITOR='nvim'
31+
export PSQL_TZ=$(date +%Z)
3132
# export AWS_DEFAULT_REGION=us-west-2 # used by aws tools. Specifically sam (maybe others)
3233

3334

@@ -45,6 +46,7 @@ PATH="${PATH}:$PYENV_ROOT/bin"
4546
PATH="${PATH}:/usr/local/sbin"
4647
PATH="$PYENV_ROOT/bin:${PATH}"
4748
PATH="${PATH}:/usr/local/bin" # for npm
49+
PATH="${PATH}:~/.dblab/"
4850
PATH="/opt/homebrew/opt/libpq/bin:$PATH"
4951

5052

@@ -180,7 +182,8 @@ export HOMEBREW_NO_AUTO_UPDATE=1
180182
# set +x
181183
# exec 2>&3 3>&-
182184
eval `ssh-agent`
183-
ssh-add ~/.ssh/id_ed25519
185+
# ssh-add ~/.ssh/id_ed25519
186+
# ssh-add ~/.ssh/id_rsa.koanix
184187

185188
# The next line updates PATH for the Google Cloud SDK.
186189
if [ -f '/Users/ethomas/Downloads/google-cloud-sdk/path.bash.inc' ]; then . '/Users/ethomas/Downloads/google-cloud-sdk/path.bash.inc'; fi
@@ -192,3 +195,13 @@ if [ -f '/Users/ethomas/Downloads/google-cloud-sdk/completion.bash.inc' ]; then
192195
export NVM_DIR="$HOME/.nvm"
193196
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
194197
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
198+
199+
# Shell-GPT integration BASH v0.2
200+
_sgpt_bash() {
201+
if [[ -n "$READLINE_LINE" ]]; then
202+
READLINE_LINE=$(sgpt --shell <<< "$READLINE_LINE" --no-interaction)
203+
READLINE_POINT=${#READLINE_LINE}
204+
fi
205+
}
206+
# bind -x '"\C-i": _sgpt_bash'
207+
# Shell-GPT integration BASH v0.2

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88
debug.py
99
.envrc
1010
.secrets.envrc
11+
.ignore
12+
.rgignore
13+
.git-blame-ignore-revs
14+
.spr.yml

.psqlrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
-- Use pspg pager
1212
-- https://github.com/okbob/pspg
13+
-- \pset pager off
1314
\setenv PAGER 'pspg -s 17'
1415
\pset border 2
1516
\pset linestyle unicode
17+
18+
-- set timezone
19+
SET TIMEZONE TO 'America/Los_Angeles';

.tmux.conf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ bind-key -T copy-mode-vi r send-keys -X rectangle-toggle
1717
unbind C-b
1818
set -g prefix C-Space
1919

20+
2021
unbind Left
2122
unbind Down
2223
unbind Up
@@ -60,6 +61,12 @@ bind Right resize-pane -R 10
6061

6162
set-option -g default-shell /bin/bash
6263

63-
run-shell ~/scrap/tmux-logging/logging.tmux
64+
# run-shell ~/scrap/tmux-logging/logging.tmux
6465
set-option -g default-shell /bin/bash
6566

67+
# Plugins
68+
set -g @plugin 'tmux-plugins/tpm'
69+
set -g @plugin 'tmux-plugins/tmux-resurrect'
70+
71+
# Initialize TPM
72+
run '~/.tmux/plugins/tpm/tpm'

.vim/.vimrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ call plug#begin('~/.vim/plugged')
2929

3030
" " Language/IDE like things
3131
" Plug 'https://github.com/dense-analysis/ale' " REally slow on mac
32-
Plug 'neoclide/coc.nvim', {'branch': 'release'}
32+
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
3333
Plug 'github/copilot.vim'
3434

3535

@@ -309,10 +309,10 @@ command! -bang -nargs=* Lines
309309
\ call fzf#vim#lines(<q-args>, fzf#vim#with_preview('right:35%'))
310310

311311
" Immediately trigger a search for the current keyword if there is one
312-
nnoremap <expr> <leader>g (expand("<cword>") ==? "") ? ":Rg " : ":Rg '\\b\<C-r>\<C-w>\\b'<CR>"
312+
nnoremap <expr> <leader>g (expand("<cword>") ==? "") ? ":Ag " : ":Ag '\\b\<C-r>\<C-w>\\b'<CR>"
313313
314314
" Immediately trigger a search for the current selection if there is one
315-
xnoremap <leader>g "zy:exe "Rg ".@z.""<CR>
315+
xnoremap <leader>g "zy:exe "Ag ".@z.""<CR>
316316
317317
let g:prettier#exec_cmd_path = "~/.config/yarn/global/node_modules/.bin/prettier"
318318
let g:prettier#exec_cmd_async = 1

scripts/mitmproxy

100755100644
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# export CURL_CA_BUNDLE=~/.mitmproxy/mitmproxy-ca-cert.cer # For curl
1010
# export SSL_CERT_FILE=~/.mitmproxy/mitmproxy-ca-cert.cer # For go
1111
# curl --data '{foo: "bar"}' https://example.com/
12-
12+
# NOTE: http_proxy is LOWERCASE ONLY!!!
1313
# The following will make libcurl look for the mitmproxy's cert without the
1414
# CURL_CA_BUNDLE env variable. It's not very useful, bc even though libcurl
1515
# will find the cert it still won't trust it bc it's self signed. It's also
@@ -19,5 +19,6 @@
1919
# is.
2020
# $ mkdir -p /usr/share/ca-certificates/extra/
2121
# $ openssl x509 -in ~/.mitmproxy/mitmproxy-ca-cert.pem -inform PEM -out /usr/share/ca-certificates/extra/mitmproxy.crt
22+
#
2223

2324
docker run --rm -it -v ~/.mitmproxy:/home/mitmproxy/.mitmproxy --network=host -p 8080:8080 mitmproxy/mitmproxy mitmproxy "$@"

scripts/mitmweb

Lines changed: 0 additions & 2 deletions
This file was deleted.

scripts/ssh-ec2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/Users/evanthomas/github.com/ethomas2/ssh-ec2/venv/bin/python /Users/evanthomas/github.com/ethomas2/ssh-ec2/main.py "$@"

scripts/stopwatch

Lines changed: 119 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,120 @@
1-
#!/bin/bash
1+
#!/Users/evanthomas/.dotfiles/scripts/venv-stopwatch/bin/python
22

3-
# stolen from https://stackoverflow.com/questions/37986523/how-can-i-create-a-stopwatch-in-bash
4-
now=$(date +%s)sec; watch -n0.1 -p TZ=UTC date --date now-$now +%H:%M:%S.%N
3+
from __future__ import annotations
4+
5+
import argparse
6+
import re
7+
import time
8+
9+
10+
def _no_curses(offset: TimeOffset | None = None):
11+
now = time.time()
12+
13+
while True:
14+
elapsed = time.time() - now + (offset.offset_seconds if offset else 0)
15+
16+
hours, remainder = divmod(int(elapsed), 3600)
17+
minutes, seconds = divmod(remainder, 60)
18+
elapsed_time = f"{hours:02}:{minutes:02}:{seconds:02}"
19+
# https://stackoverflow.com/questions/37774983/clearing-the-screen-by-printing-a-character
20+
print("\033c")
21+
print(elapsed_time, end="\n\r")
22+
time.sleep(1)
23+
24+
25+
def _curses(offset: TimeOffset | None = None):
26+
import curses
27+
28+
def _run(stdscr):
29+
# Initialize curses
30+
curses.curs_set(0) # Hide the cursor
31+
stdscr.clear() # Clear the screen
32+
33+
now = time.time()
34+
while True:
35+
# Calculate elapsed time
36+
elapsed = time.time() - now + (offset.offset_seconds if offset else 0)
37+
hours, remainder = divmod(int(elapsed), 3600)
38+
minutes, seconds = divmod(remainder, 60)
39+
elapsed_time = f"{hours:02}:{minutes:02}:{seconds:02}"
40+
41+
# Display elapsed time in the center of the screen
42+
height, width = stdscr.getmaxyx()
43+
x = width // 2 - len(elapsed_time) // 2
44+
y = height // 2
45+
stdscr.addstr(y, x, elapsed_time)
46+
stdscr.refresh()
47+
48+
time.sleep(1)
49+
50+
curses.wrapper(_run)
51+
52+
53+
class TimeOffset:
54+
def __init__(self, offset_seconds: int):
55+
self.offset_seconds = offset_seconds
56+
57+
@classmethod
58+
def parse(cls, time_str: str) -> TimeOffset | None:
59+
"""
60+
time_str is like 5m, 1h, '5minutes', '5 minutes', '1 hour'
61+
"""
62+
pattern = r"(?P<value>\d+)\s*(?P<unit>\w+)$"
63+
m = re.match(pattern, time_str)
64+
if m is None:
65+
return None
66+
67+
value = int(m.group("value"))
68+
unit = m.group("unit")
69+
70+
conversion = {
71+
"m": 60,
72+
"minute": 60,
73+
"minutes": 60,
74+
"h": 3600,
75+
"hour": 3600,
76+
"hours": 3600,
77+
"s": 1,
78+
"second": 1,
79+
"seconds": 1,
80+
}.get(unit)
81+
if conversion is None:
82+
raise ValueError(f"Unknown unit {unit}")
83+
return TimeOffset(conversion * value)
84+
85+
86+
def test_time_offset():
87+
good_patterns = [
88+
("5m", 300),
89+
("5 m", 300),
90+
("5minutes", 300),
91+
("5 minutes", 300),
92+
("5s", 5),
93+
("5 second", 5),
94+
("5hour", 18_000),
95+
("5h", 18_000),
96+
]
97+
for time_str, expected_offset in good_patterns:
98+
o = TimeOffset.parse(time_str)
99+
assert o is not None, f"Expected {time_str} to parse, got None"
100+
assert (
101+
o.offset_seconds == expected_offset
102+
), f"Expected {expected_offset=} for {time_str=} got {o.offset_seconds=}"
103+
104+
105+
def main():
106+
parser = argparse.ArgumentParser()
107+
parser.add_argument(
108+
"--no-curses", action="store_true", help="Use plain text instead of curses"
109+
)
110+
parser.add_argument("--offset", type=TimeOffset.parse, required=False)
111+
112+
args = parser.parse_args()
113+
if args.no_curses:
114+
_no_curses(offset=args.offset)
115+
else:
116+
_curses(offset=args.offset)
117+
118+
119+
if __name__ == "__main__":
120+
main()

0 commit comments

Comments
 (0)