-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.zshenv
More file actions
43 lines (35 loc) · 1.09 KB
/
.zshenv
File metadata and controls
43 lines (35 loc) · 1.09 KB
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
#!/bin/zsh
# deduplicate PATH entries (useful when .zprofile is re-sourced, e.g., zellij)
typeset -U PATH path
# Used by helix blame shortcut to get the most recent commit that will not 404
# on GitHub. Solves the problem of trying to open a blame on a commit that's not
# pushed yet.
function latest_pushed_commit() {
local current_branch=$(git rev-parse --abbrev-ref HEAD)
local current_commit=$(git rev-parse HEAD)
local remote_commit=$(git ls-remote origin $current_branch | cut -f1)
local main_commit=$(git ls-remote origin main | cut -f1)
if [ "$current_commit" = "$remote_commit" ]; then
echo $current_commit
elif [ -n "$remote_commit" ]; then
echo $remote_commit
else
echo $main_commit
fi
}
function stag() {
echo "<xxx>"
cat
echo "</xxx>"
}
alias format_sql='cockroach sqlfmt --print-width 80 --use-spaces'
# this is here for nushell
export XDG_CONFIG_HOME="$HOME/.config"
function oxfmt-stdin() {
local ext="${1:-ts}"
local temp_file="$(mktemp /tmp/oxfmt.${ext})"
cat > "$temp_file"
bunx oxfmt "$temp_file" > /dev/null
cat "$temp_file"
rm "$temp_file"
}