summaryrefslogtreecommitdiffstats
path: root/modules/tv/environment.nix
blob: f901ef68290e6b784d9d7dc1991e6e6f7c362b85 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ pkgs, ... }:

let
  lib = import ../../lib { lib = pkgs.lib; inherit pkgs; };

  inherit (lib) majmin;
in

{
  environment.systemPackages = with pkgs; [
    vim
  ];

  environment.etc."vim/vimrc".text = ''
    set nocp
  '';

  environment.etc."vim/vim${majmin pkgs.vim.version}".source =
      "${pkgs.vim}/share/vim/vim${majmin pkgs.vim.version}";

  # multiple-definition-problem when defining environment.variables.EDITOR
  environment.extraInit = ''
    EDITOR=vim
  '';

  environment.shellAliases = {
    # alias cal='cal -m3'
    gp = "${pkgs.pari}/bin/gp -q";
    df = "df -h";
    du = "du -h";
    # alias grep='grep --color=auto'

    # TODO alias cannot contain #\'
    # "ps?" = "ps ax | head -n 1;ps ax | fgrep -v ' grep --color=auto ' | grep";

    # alias la='ls -lA'
    lAtr = "ls -lAtr";
    # alias ll='ls -l'
    ls = "ls -h --color=auto --group-directories-first";
    # alias vim='vim -p'
    # alias vi='vim'
    # alias view='vim -R'
    dmesg = "dmesg -L --reltime";
  };

  environment.variables.VIM = "/etc/vim";

  programs.bash = {
    interactiveShellInit = ''
      HISTCONTROL='erasedups:ignorespace'
      HISTSIZE=65536
      HISTFILESIZE=$HISTSIZE

      shopt -s checkhash
      shopt -s histappend histreedit histverify
      shopt -s no_empty_cmd_completion
      complete -d cd

      # TODO source bridge
    '';
    promptInit = ''
      case $UID in
        0)
          PS1='\[\e[1;31m\]\w\[\e[0m\] '
          ;;
        1337)
          PS1='\[\e[1;32m\]\w\[\e[0m\] '
          ;;
        *)
          PS1='\[\e[1;35m\]\u \[\e[1;32m\]\w\[\e[0m\] '
          ;;
      esac
      if test -n "$SSH_CLIENT"; then
        PS1='\[\e[35m\]\h'" $PS1"
      fi
      if test -n "$SSH_AGENT_PID"; then
        PS1="ssh-agent[$SSH_AGENT_PID] $PS1"
      fi
    '';
  };

  programs.ssh.startAgent = false;
}