2024-01-29 17:11:15 +01:00
|
|
|
#!/bin/zsh
|
2023-11-20 14:30:34 +01:00
|
|
|
venv_prompt() {
|
2024-01-13 15:10:31 +01:00
|
|
|
[[ -n ${VIRTUAL_ENV} ]] || return
|
|
|
|
echo -e "%F{yellow}%f ${VIRTUAL_ENV:t:gs/%/%%}"
|
2023-11-20 14:30:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function write_title_cmd() {
|
|
|
|
if [ ${1[(w)1]} != "lfwrap" ]; then
|
|
|
|
echo -ne "\033]0;$(print -P "%n@%m [%3~] » ${1[(w)1]}")\007"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2024-01-29 15:21:15 +01:00
|
|
|
function write_title_wd() { echo -ne "\033]0;$(print -P "%n@%m [%3~]")\007"; }
|
2023-11-20 14:30:34 +01:00
|
|
|
|
2024-01-29 15:21:15 +01:00
|
|
|
function reset_beam() { echo -ne '\e[5 q'; }
|
2023-06-12 19:48:29 +02:00
|
|
|
|
2023-06-13 19:13:27 +02:00
|
|
|
function lfwrap () {
|
2024-02-01 18:47:57 +01:00
|
|
|
export EMBEDDED=true
|
2023-06-13 19:13:27 +02:00
|
|
|
LF_DIRFILE="/tmp/lfdir.$(uuidgen)"
|
2024-02-01 18:47:57 +01:00
|
|
|
lfX -last-dir-path="$LF_DIRFILE"
|
2023-06-13 19:13:27 +02:00
|
|
|
dir="$(cat "$LF_DIRFILE")"
|
|
|
|
rm "$LF_DIRFILE"
|
|
|
|
if [ -d "$dir" ]; then
|
|
|
|
if [ "$dir" != "$(pwd)" ]; then
|
|
|
|
cd "$dir"
|
|
|
|
fi
|
|
|
|
fi
|
2023-11-20 14:30:34 +01:00
|
|
|
zle reset-prompt
|
|
|
|
zle redisplay
|
|
|
|
write_title_wd
|
|
|
|
reset_beam
|
2023-06-13 19:13:27 +02:00
|
|
|
}
|
|
|
|
|
2023-11-20 14:30:34 +01:00
|
|
|
zle -N lfwrap
|
2023-03-29 16:15:06 +02:00
|
|
|
|
|
|
|
# Cursor Shape
|
|
|
|
function zle-keymap-select () {
|
|
|
|
case $KEYMAP in
|
|
|
|
vicmd) echo -ne '\e[1 q';; # block
|
|
|
|
viins|main) echo -ne '\e[5 q';; # beam
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
zle -N zle-keymap-select
|
|
|
|
zle-line-init() {
|
|
|
|
zle -K viins # initiate `vi insert` as keymap (can be removed if `bindkey -V` has been set elsewhere)
|
|
|
|
echo -ne "\e[5 q"
|
|
|
|
}
|
|
|
|
zle -N zle-line-init
|
|
|
|
|
|
|
|
# CMDLine Edit
|
|
|
|
zle -N edit-command-line
|
|
|
|
|
|
|
|
# Lazygit
|
|
|
|
function lg () {
|
2023-06-12 19:48:29 +02:00
|
|
|
[ ! -d "$(pwd)/.git" ] && [[ $(read -erk "?Not in a git repository. Create a new git repository? (y/n): ") =~ ^[Yy]$ ]] && git init
|
|
|
|
[ -d "$(pwd)/.git" ] && lazygit -p "$(pwd)"
|
|
|
|
zle reset-prompt
|
2023-03-29 16:15:06 +02:00
|
|
|
}
|
2023-11-24 16:57:21 +01:00
|
|
|
zle -N lg
|