-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathzshrc
More file actions
138 lines (109 loc) · 3.29 KB
/
zshrc
File metadata and controls
138 lines (109 loc) · 3.29 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
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
# ZSH
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
# Avoid % in prompt
set +o prompt_cr +o prompt_sp
# Shell
eval "$(sheldon -q --non-interactive source)"
eval "$(starship init zsh)"
setopt autocd extendedglob
setopt hist_ignore_all_dups
setopt hist_reduce_blanks
setopt inc_append_history
setopt share_history
setopt correct
setopt auto_menu
bindkey -e
# Completions
zstyle :compinstall filename '/home/david/.zshrc'
zstyle ':completion:*' menu select
autoload -Uz compinit
compinit
# Aliases
alias cd='z'
alias ls='eza'
alias ll='eza -l'
alias la='eza -la'
alias up='paru -Syu --devel --skipreview'
alias c='cursor --ozone-platform=wayland --enable-features=UseOzonePlatform .'
alias tn='tod task create -p Personal -u Today -l "" --priority 1 -c'
alias tnw='tod task create -p Work -u Today -l "" --priority 1 -c'
alias tls='tod list view -f "Today"'
alias chat='llm chat -m gpt-4o'
# Functions
aigcm() {
git add -A .
git diff --minimal --cached | \
llm -t gitcommit > $(git rev-parse --git-dir)/COMMIT_EDITMSG && \
git commit --verbose --edit --file=$(git rev-parse --git-dir)/COMMIT_EDITMSG
}
q() {
local url="$1"
local question="$2"
# Fetch the URL content through Jina
local content=$(curl -s "https://r.jina.ai/$url")
# Check if the content was retrieved successfully
if [ -z "$content" ]; then
echo "Failed to retrieve content from the URL."
return 1
fi
system="
You are a helpful assistant that can answer questions about the content.
Reply concisely, in a few sentences.
The content:
${content}
"
# Use llm with the fetched content as a system prompt
llm prompt "$question" -s "$system"
}
qv() {
local url="$1"
local question="$2"
# Fetch the URL content through Jina
local subtitle_url=$(yt-dlp -q --skip-download --convert-subs srt --write-sub --sub-langs "en" --write-auto-sub --print "requested_subtitles.en.url" "$url")
local content=$(curl -s "$subtitle_url" | sed '/^$/d' | grep -v '^[0-9]*$' | grep -v '\-->' | sed 's/<[^>]*>//g' | tr '\n' ' ')
# Check if the content was retrieved successfully
if [ -z "$content" ]; then
echo "Failed to retrieve content from the URL."
return 1
fi
system="
You are a helpful assistant that can answer questions about YouTube videos.
Reply concisely, in a few sentences.
The content:
${content}
"
# Use llm with the fetched content as a system prompt
llm prompt "$question" -s "$system"
}
# FZF
source <(fzf --zsh)
# Zoxide
eval "$(zoxide init zsh)"
# Expand PATH with $HOME/.local/bin
export PATH=$HOME/.local/bin:$PATH
# SSH Agent
if [ -z "$SSH_AUTH_SOCK" ]; then
# Check for a currently running instance of the agent
RUNNING_AGENT="`ps -ax | grep 'ssh-agent -s' | grep -v grep | wc -l | tr -d '[:space:]'`"
if [ "$RUNNING_AGENT" = "0" ]; then
# Launch a new instance of the agent
ssh-agent -s &> $HOME/.ssh/ssh-agent
fi
eval `cat $HOME/.ssh/ssh-agent` > /dev/null
# Add all keys
ssh-add
fi
# Move cursor
bindkey "^[[1;5C" forward-word
bindkey "^[[1;3C" forward-word
bindkey "^[[1;3D" backward-word
bindkey "^[[1;5D" backward-word
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND='bg=blue,fg=black,bold'
# Hyprland
if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
exec Hyprland
fi