fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert Helgessonvte: add modulebb567e20

master
1.6 KiB51 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5{
6  meta.maintainers = [ maintainers.rycee ];
7
8  options.programs = let
9    description = ''
10      Whether to enable integration with terminals using the VTE
11      library. This will let the terminal track the current working
12      directory.
13    '';
14  in {
15    bash.enableVteIntegration = mkEnableOption "" // { inherit description; };
16
17    zsh.enableVteIntegration = mkEnableOption "" // { inherit description; };
18  };
19
20  config = mkMerge [
21    (mkIf config.programs.bash.enableVteIntegration {
22      # Unfortunately we have to do a little dance here to fix two
23      # problems with the upstream vte.sh file:
24      #
25      #  - It does `PROMPT_COMMAND="__vte_prompt_command"` which
26      #    clobbers any previously assigned prompt command.
27      #
28      #  - Its `__vte_prompt_command` function runs commands that will
29      #    overwrite the exit status of the command the user ran.
30      programs.bash.initExtra = ''
31        __HM_PROMPT_COMMAND="''${PROMPT_COMMAND:+''${PROMPT_COMMAND%;};}__hm_vte_prompt_command"
32        . ${pkgs.vte}/etc/profile.d/vte.sh
33        if [[ $(type -t __vte_prompt_command) = function ]]; then
34          __hm_vte_prompt_command() {
35            local old_exit_status=$?
36            __vte_prompt_command
37            return $old_exit_status
38          }
39          PROMPT_COMMAND="$__HM_PROMPT_COMMAND"
40        fi
41        unset __HM_PROMPT_COMMAND
42      '';
43    })
44
45    (mkIf config.programs.zsh.enableVteIntegration {
46      programs.zsh.initExtra = ''
47        . ${pkgs.vte}/etc/profile.d/vte.sh
48      '';
49    })
50  ];
51}