revamp .zshrc a bit.

This commit is contained in:
Gabe Venberg 2025-05-14 00:16:40 +02:00
parent 73aa17f319
commit 6aabb86c2c

View file

@ -20,8 +20,6 @@
#default options for less
export LESS="-R"
export LESSHISTFILE="/dev/null"
#set the w3m homepage
export WWW_HOME="duckduckgo.com/lite/"
#set ssh-agent to play nice with systemd.
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
export TIMEFMT="%J %*U user %*S system %P cpu %*E total"
@ -45,7 +43,7 @@ setprompt() {
setopt prompt_subst
precmd_vcs() {vcs_info}
precmd_vcs() { vcs_info; }
#when not in a repo, show full path to current directory. when in one, show path from base direcory of the repo.
zstyle ':vcs_info:*' nvcsformats '%~'
@ -53,9 +51,7 @@ setprompt() {
zstyle ':vcs_info:*' actionformats '%r/%S %F{green}[%b] %F{red}<%a>%f'
#the precmd function, called just before printing the prompt.
function precmd() {
precmd_vcs
}
function precmd() { precmd_vcs; }
#Make the right prompt blank, just to be sure.
RPROMPT=''
@ -91,6 +87,8 @@ setprompt() {
#misc
# Sends cd commands without the need for 'cd'
setopt AUTO_CD
# Turn off terminal beep on autocomplete.
unsetopt BEEP
# Kill all child processes when we exit, dont leave them running
unsetopt NO_HUP
#Allows comments in interactive shell.
@ -177,22 +175,40 @@ setprompt() {
#fzf stuff
testPath="/usr/share/fzf/key-bindings.zsh"
[ -f "$testPath" ] && source $testPath
[ -f "$testPath" ] && source "$testPath"
testPath="/usr/share/fzf/completion.zsh"
[ -f "$testPath" ] && source $testPath
[ -f "$testPath" ] && source "$testPath"
#if it was installed using git, can just source the one file:
testPath="$HOME/.fzf.zsh"
[ -f "$testPath" ] && source $testPath
[ -f "$testPath" ] && source "$testPath"
#zoxide stuff
command -v zoxide &> /dev/null && eval "$(zoxide init zsh)"
#check for existence of pyenv before setting it up.
if command -v pyenv &> /dev/null; then
export PYENV_ROOT="$HOME/.pyenv"
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
#cheat.sh is a wonderful tool, the less typing needed the better.
cheat(){
for i in "$@"; do
curl cheat.sh/"$i"
done
}
#the tre command has some shell integration.
tre() { command tre "$@" --editor && source "/tmp/tre_aliases_$USER" 2>/dev/null; }
tred() { command tre "$@" --editor=z --directories && source "/tmp/tre_aliases_$USER" 2>/dev/null; }
#moves a file, leaving a symlink in its place.
mvln(){
# Check for correct number of arguments
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <source> <destination>"
exit 1
fi
source="$1" destination="$2"
# Check if source exists
if [ ! -e "$source" ]; then
echo "$source does not exist."
exit 1
fi
#fancy way of testing if a command exists
command -v ruby &>/dev/null && export PATH="$PATH:$(ruby -e 'puts Gem.user_dir' 2> /dev/null)/bin/"
mv -- "$source" "$destination"
ln -s -- "$(realpath "$destination/$(basename "$source")")" "$(realpath "$source")"
}