summaryrefslogtreecommitdiff
path: root/config/essentials/zsh/widgets.zsh
blob: 985ad2b494573649e0a4ae2f3eba720e4ccf492a (plain)
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
# Surround line in variable
surround_in_var() {
	BUFFER=" \"\$($BUFFER)\""
	zle beginning-of-line
}
zle -N surround_in_var
bindkey '\ev' surround_in_var

# Insert output from the previous command
zmodload -i zsh/parameter
insert-last-command-output() {
	LBUFFER+="$(eval $history[$((HISTCMD - 1))])"
}
zle -N insert-last-command-output
bindkey "^Xl" insert-last-command-output


toggle_prompt() {
    local new_prompt=' $ '
    if [ "$PS1" = "$new_prompt" ]; then
        eval "$(starship init zsh)"
    else
        PS1="$new_prompt"
    fi
    zle clear-screen
}
zle -N toggle_prompt
bindkey '\ep' toggle_prompt


bindkey -s "^f" "tmux-sessionizer\n"