From 82729bf33603d4058911b3e38d9efb21098bdc34 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Thu, 18 Aug 2022 16:12:16 -0400 Subject: [PATCH] tweak(qtile): run commands in zsh for shell features --- users/infinidoge/config/qtile/config.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/users/infinidoge/config/qtile/config.py b/users/infinidoge/config/qtile/config.py index 90959b3..e0a34b3 100644 --- a/users/infinidoge/config/qtile/config.py +++ b/users/infinidoge/config/qtile/config.py @@ -54,6 +54,13 @@ class Apps: """ return f"{terminal or cls.TERMINAL} {' '.join(args)} -- {program}" + @classmethod + def shell_command(cls, command, args=tuple(), *, shell=None): + """ + Returns a string of a command to run a command in the shell, with the given arguments. + """ + return f'{shell or cls.SHELL} {" ".join(args)} -- "{command}"' + @classmethod def open_in_terminal(cls, program, args=tuple(), *, terminal=None): """ @@ -61,6 +68,17 @@ class Apps: """ return lazy.spawn(cls.terminal_command(program, args=args, terminal=terminal)) + @classmethod + def shell_in_terminal( + cls, command, sargs=tuple(), targs=tuple(), *, shell=None, terminal=None + ): + """ + Opens a program in the terminal using the shell, with the given shell and terminal arguments. + """ + return cls.open_in_terminal( + cls.shell_command(command, sargs, shell=shell), targs, terminal=terminal + ) + @classmethod def open_in_editor(cls, file_, args=tuple()): """ @@ -261,12 +279,12 @@ keys = [ # Keys for spawning commands or applications Key( [Keys.SUPER], "r", - lazy.spawncmd(), + lazy.spawncmd(command=Apps.shell_command("%s", args=("-ic",))), desc="Spawn a command using a prompt widget", ), Key( [Keys.SUPER, Keys.SHIFT], "r", - lazy.spawncmd(prompt="shell", command=Apps.terminal_command("%s", args=("--hold",))), + lazy.spawncmd(prompt="shell", command=Apps.terminal_command(Apps.shell_command("%s", args=("-ic",)), args=("--hold",))), desc="Spawn a command in a shell using a prompt widget", ), Key(