about summary refs log tree commit diff
path: root/home/modules/shell.nix
blob: 69672473af233339dfe072f98c7eadeb0cf7a1e2 (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
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
{ config, lib, pkgs, ... }:
let
  shellAliases = rec {
    # NixOS stuff
    hms = "home-manager switch";
    nor = "sudo nixos-rebuild switch";
    nrs = nor;
    nrb = "sudo nixos-rebuild boot";
    ncg = "nix-collect-garbage";
    vihome = "vim ~/code/system/home/home.nix && home-manager switch";
    virc = "vim ~/code/system/home/modules/shell.nix && home-manager switch && source ~/.zshrc";
    visystem = "sudo vim /etc/nixos/configuration.nix && sudo nixos-rebuild switch";

    # Nix
    ns = "nix-shell";
    nb = "nix build -f .";
    nc = "nix copy --to https://nix.urbinternal.com";
    "nc." = "nix copy -f . --to https://nix.urbinternal.com";

    # Docker and friends
    "dcu" = "docker-compose up";
    "dcud" = "docker-compose up -d";
    "dc" = "docker-compose";
    "dcr" = "docker-compose restart";
    "dclf" = "docker-compose logs -f";
    "dck" = "docker";
    "dockerclean" = "dockercleancontainers && dockercleanimages";
    "dockercleanimages" = "docker images -a --no-trunc | grep none | awk '{print \$$3}' | xargs -L 1 -r docker rmi";
    "dockercleancontainers" = "docker ps -a --no-trunc| grep 'Exit' | awk '{print \$$1}' | xargs -L 1 -r docker rm";

    # Git
    "gwip" = "git add . && git commit -am wip";
    "gpr" = "g pull-request";
    "gcl" = "git clone";
    "grs" = "gr --soft";
    "grhh" = "grh HEAD";
    "grh" = "gr --hard";
    "gr" = "git reset";
    "gcb" = "gc -b";
    "gco" = "gc";
    "gcd" = "gc development";
    "gcm" = "gc master";
    "gc" = "git checkout";
    "gbg" = "git branch | grep";
    "gba" = "git branch -a";
    "gb" = "git branch";
    "gcv" = "git commit --verbose";
    "gci" = "git commit";
    "gm" = "git merge";
    "gdc" = "gd --cached";
    "gd" = "git diff";
    "gsl" = "git stash list";
    "gss" = "git show stash";
    "gsad" = "git stash drop";
    "gsa" = "git stash";
    "gst" = "gs";
    "gs" = "git status";
    "gg" = "gl --decorate --oneline --graph --date-order --all";
    "gl" = "git log";
    "gf" = "git fetch";
    "gur" = "gu --rebase";
    "gu" = "git pull";
    "gpf" = "gp -f";
    "gpa" = "gp --all";
    "gpu" = "git push -u origin \"$(git symbolic-ref --short HEAD)\"";
    "gp" = "git push";
    "ganw" = "git diff -w --no-color | git apply --cached --ignore-whitespace";
    "ga" = "git add";
    "gnp" = "git --no-pager";
    "g" = "git";
    "git" = "hub";
    "grim" = "git fetch && git rebase -i origin/master";
    "grc" = "git rebase --continue";
    "gcan" = "git commit --amend --no-edit";
    "grl" = "git reflog";

    # Aliases from old config
    stck = "dirs -v";
    b= "cd ~1";
    ".." = "cd ..";
    "..." = "cd ../..";
    "...." = "cd ../../..";
    "....." = "cd ../../../..";
    "http" = "http --style solarized";
    "grep" = "grep $GREP_OPTIONS";
    "bak" = "~/bin/backup.sh";
    "xmm" = "xmodmap ~/.Xmodmap";
    "asdflkj" = "asdf";
    "asdf" = "asdfghjkl";
    "asdfghjkl" = "echo \"Having some trouble?\"";
    "ift" = "sudo iftop -i wlp3s0";
    "mytl" = "t tl $TWITTER_WHOAMI";
    "first" = "awk '{print \$$1}'";
    "cmt" = "git log --oneline | fzf-tmux | awk '{print \$$1}'";
    "workmon" = "xrandr --output DP-2 --pos 1440x900 --primary";
    "vi" = "vim";
    "adbdev" = "adb devices";
    "adbcon" = "adb connect $GNEX_IP";
    "mpalb" = "mpc search album";
    "mpart" = "mpc search artist";
    "mps" = "mpc search";
    "mpa" = "mpc add";
    "mpt" = "mpc toggle";
    "mpl" = "mpc playlist";
    "dsstore" = "find . -name '*.DS_Store' -type f -ls -delete";
    "df" = "df -h";
    "fs" = "stat -f '%z bytes'";
    "ll" = "ls -al";
    "la" = "ls -a";
  };
in {
  home.packages = with pkgs; [
    zsh
    autojump
  ];

  home.sessionVariables = {
    EDITOR = "vim";
    LS_COLORS = "no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:";
    TWITTER_WHOAMI = "glittershark1";
    BROWSER = "firefox";
  };

  programs.bash = {
    enable = true;
    inherit shellAliases;
  };

  programs.zsh = {
    enable = true;
    enableAutosuggestions = true;
    autocd = true;

    inherit shellAliases;

    history = rec {
      save = 100000;
      size = save;
    };

    oh-my-zsh = {
      enable = true;

      plugins = [
        "battery"
        "colorize"
        "command-not-found"
        "github"
        "gitignore"
        "postgres"
        "systemd"
        "themes"
        "vi-mode"
      ];

      custom = "${pkgs.stdenv.mkDerivation {
        name = "oh-my-zsh-custom";
        unpackPhase = ":";
        installPhase = ''
          mkdir -p $out/themes
          mkdir -p $out/custom/plugins
          ln -s ${./pure.zsh-theme} $out/themes/pure.zsh-theme
        '';
      }}";

      theme = "pure";
    };

    plugins = [{
      name = "pure-theme";
      src = pkgs.fetchFromGitHub {
        owner = "sindresorhus";
        repo = "pure";
        rev = "0a92b02dd4172f6c64fdc9b81fe6cd4bddb0a23b";
        sha256 = "0l8jqhmmjn7p32hdjnv121xsjnqd2c0plhzgydv2yzrmqgyvx7cc";
      };
    }];

    initExtraBeforeCompInit = ''
      zstyle ':completion:*' completer _complete _ignored _correct _approximate
      zstyle ':completion:*' matcher-list \'\' 'm:{[:lower:]}={[:upper:]} m:{[:lower:][:upper:]}={[:upper:][:lower:]} r:|[._- :]=** r:|=**' 'l:|=* r:|=*'
      zstyle ':completion:*' max-errors 5
      zstyle ':completion:*' use-cache yes
      zstyle ':completion::complete:grunt::options:' expire 1
      zstyle ':completion:*' prompt '%e errors'
      # zstyle :compinstall filename '~/.zshrc'
      autoload -Uz compinit
    '';

    initExtra = ''
      source ${./zshrc}
      source ${pkgs.fetchFromGitHub {
        owner = "zsh-users";
        repo = "zsh-syntax-highlighting";
        rev = "7678a8a22780141617f809002eeccf054bf8f448";
        sha256 = "0xh4fbd54kvwwpqvabk8lpw7m80phxdzrd75q3y874jw0xx1a9q6";
      }}/zsh-syntax-highlighting.zsh
      source ${pkgs.autojump}/share/autojump/autojump.zsh
      source ${pkgs.fetchFromGitHub {
        owner = "chisui";
        repo = "zsh-nix-shell";
        rev = "a65382a353eaee5a98f068c330947c032a1263bb";
        sha256 = "0l41ac5b7p8yyjvpfp438kw7zl9dblrpd7icjg1v3ig3xy87zv0n";
      }}/nix-shell.plugin.zsh

      export RPS1=""
      autoload -U promptinit; promptinit
      prompt pure

      if [[ "$TERM" == "dumb" ]]; then
        unsetopt zle
        unsetopt prompt_cr
        unsetopt prompt_subst
        unfunction precmd
        unfunction preexec
        export PS1='$ '
      fi
    '';
  };

  programs.fzf = {
    enable = true;
    enableBashIntegration = true;
    enableZshIntegration = true;
  };
}