summaryrefslogtreecommitdiff
path: root/user/zsh/zshrc-graphical.sh
blob: d60c15a8453c8b2f0b57184464b52a177ce55fd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# This file is sourced by .zshrc if parts/graphical.nix was imported.

if [ $TERM = foot ]; then
    # Enable spawning of new terminal instances in the current working directory
    function osc7-pwd() {
        emulate -L zsh # also sets localoptions for us
        setopt extendedglob
        local LC_ALL=C
        printf '\e]7;file://%s%s\e\' $HOST ${PWD//(#m)([^@-Za-z&-;_~])/%${(l:2::0:)$(([##16]#MATCH))}}
    }

    function chpwd-osc7-pwd() {
        (( ZSH_SUBSHELL )) || osc7-pwd
    }
    add-zsh-hook -Uz chpwd chpwd-osc7-pwd
fi