summaryrefslogtreecommitdiffstats
path: root/nixos/modules/config/vte.nix
blob: f3ec58012b0d8d885016f336b3519d19e088b6c6 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
  config,
  pkgs,
  lib,
  ...
}:
let

  vteInitSnippet = ''
    # Show current working directory in VTE terminals window title.
    # Supports both bash and zsh, requires interactive shell.
    . ${
      pkgs.vte.override {
        withApp = false;
        gtkVersion = null;
      }
    }/etc/profile.d/vte.sh
  '';

in

{

  meta = {
    teams = [ lib.teams.gnome ];
  };

  options = {

    programs.bash.vteIntegration = lib.mkOption {
      default = false;
      type = lib.types.bool;
      description = ''
        Whether to enable Bash integration for VTE terminals.
        This allows it to preserve the current directory of the shell
        across terminals.
      '';
    };

    programs.zsh.vteIntegration = lib.mkOption {
      default = false;
      type = lib.types.bool;
      description = ''
        Whether to enable Zsh integration for VTE terminals.
        This allows it to preserve the current directory of the shell
        across terminals.
      '';
    };

  };

  config = lib.mkMerge [
    (lib.mkIf config.programs.bash.vteIntegration {
      programs.bash.interactiveShellInit = lib.mkBefore vteInitSnippet;
    })

    (lib.mkIf config.programs.zsh.vteIntegration {
      programs.zsh.interactiveShellInit = vteInitSnippet;
    })
  ];
}