about summary refs log tree commit diff stats
path: root/modules/by-name/zs/zsh/config/edit_command_line.zsh
blob: e14da5c687fefd4df3cf2a53c229db2767541869 (plain) (blame)
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
#! /usr/bin/env zsh

# nixos-config - My current NixOS configuration
#
# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
# SPDX-License-Identifier: GPL-3.0-or-later
#
# This file is part of my nixos-config.
#
# You should have received a copy of the License along with this program.
# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.

autoload -Uz edit-command-line

wrapped_edit-command-line() {
    # This overrides a print implementation in my shell lib
    print() {
        # FIXME: `print` is called in the following way from `edit-command-line`
        # (from: https://raw.githubusercontent.com/zsh-users/zsh/refs/heads/master/Functions/Zle/edit-command-line):
        #   ```
        #   (( $+zle_bracketed_paste )) && print -r -n - $zle_bracketed_paste[1]
        #   ```
        # This results in the error, that the `-r|-n` arguments are mutually exclusive with
        # the `-` arg. I'm sure, that this is not a bug (as it's been in there for quite
        # some time now), and ignoring it just seems to work.
        # But I should either really fix this or find a explanation *why* they are doing
        # it. <2024-10-21>
        builtin print "$*" 2>/dev/null
    }

    # Execute the original `edit-command-line`
    edit-command-line
}

zle -N edit-command-line wrapped_edit-command-line