about summary refs log tree commit diff stats
path: root/cleave
Commit message (Expand)AuthorAgeFilesLines
* 3447 - drop dependence on GNU makeKartik K. Agaram2016-10-061-7/+0
* 3413Kartik K. Agaram2016-09-241-2/+5
* 3288 - cleaner heuristic for cleavingKartik K. Agaram2016-08-311-10/+6
* 3284Kartik K. Agaram2016-08-301-6/+6
* 3281 - faster incremental builds for layersKartik K. Agaram2016-08-292-0/+251
0'>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
{ config, pkgs, lib, ... }:

{
  home.packages = with pkgs; [
    zsh-completions
  ];

  programs.fzf = {
    enable = true;
    enableZshIntegration = true;
  };
  programs.zoxide = {
    enable = true;
    enableZshIntegration = true;
  };
  programs.direnv = {
    enable = true;
    nix-direnv.enable = true;
  };
  programs.keychain = {
    enable = lib.mkIf pkgs.stdenv.isLinux true;
    agents = [ "ssh" "gpg"];
    keys = [ "id_rsa" "id_ed25519" "C171251002C200F2" ];
  #  extraFlags = [ "--quiet" "--ignore-missing" ];
  };
  programs.zsh = {
    enable = true;
    enableCompletion = true;
    enableAutosuggestions = true;
    defaultKeymap = "emacs";
    history = {
      size = 100000;
      save = 100000;
    };

    envExtra = ''
      export LSP_USE_PLISTS=true
      export LESS=-iRXF
    '';
    profileExtra = ''
      [[ -f ~/.nix-profile/etc/profile.d/nix.sh ]] && . ~/.nix-profile/etc/profile.d/nix.sh
      path=(~/bin
            ~/.local/bin
            ~/go/bin/
            $path)
    '';
    shellAliases = {
      cp = "cp -iv";
      mv = "mv -iv";
      mkdir = "mkdir -v";
      pp = "pushbullet push \"Pixel\" link \"\${1}\" \"\${1}\"";
      upgrade_emacs = "emacs -Q --batch -L \"~/.emacs.d/lisp/\" -l \"init-packages.el\" -f \"my/upgrade-packages\"";

      # Git log aliases from the omz git plugin
      gl = "git pull";
      glg = "git log --stat";
      glgp = "git log --stat -p";
      glgg = "git log --graph";
      glgga = "git log --graph --decorate --all";
      glgm = "git log --graph --max-count=10";
      glo = "git log --oneline --decorate";
      glol = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset\"";
      glols = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset\" --stat";
      glod = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset\"";
      glods = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ad) %C(bold blue)<%an>%Creset\" --date=short";
      glola = "git log --graph --pretty=\"%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset\" --all";
      glog = "git log --oneline --decorate --graph";
      gloga = "git log --oneline --decorate --graph --all";
    };
         
    initExtra = ''
      # Taken from prezto tmux plugin
      if [[ -z "$TMUX" && -z "$EMACS" && -z "$VIM" && -z "$INSIDE_EMACS" && -z "$SSH_TTY" ]]; then
        tmux start-server

        if ! tmux has-session 2> /dev/null; then
          tmux new-session -d -s "0" \; set-option -t "0" destroy-unattached off &> /dev/null
        fi

        exec tmux -u attach-session -d
      fi

      export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow -g "!{.git,node_modules}/*" 2> /dev/null'
      export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
      export FZF_ALT_C_COMMAND="rg --hidden --files --sort-files --null | xargs -0 dirname | sort -u"
      if [ -d "~/fzf-git" ]; then
        source ~/fzf-git/functions.sh
        source ~/fzf-git/key-binding.zsh
      fi
      
      autopair-init
      enable-fzf-tab
      bindkey '^[[A' history-substring-search-up
      bindkey '^[[B' history-substring-search-down

      # disable sort when completing `git checkout`
      zstyle ''\':completion:*:git-checkout:*''\' sort false
      # set descriptions format to enable group support
      zstyle ''\':completion:*:descriptions''\' format ''\'[%d]''\'
      # Allow tab to expand aliases
      zstyle ':completion:*' completer _expand_alias _complete _ignored
      # set list-colors to enable filename colorizing
      #zstyle ''\':completion:*''\' list-colors ''${(s.:.)LS_COLORS}
      # preview directory''\'s content with exa when completing cd
      zstyle ''\':fzf-tab:complete:cd:*''\' fzf-preview ''\'exa -1 --color=always ''$realpath''\'
      # switch group using `,` and `.`
      zstyle ''\':fzf-tab:*''\' switch-group ''\',''\' ''\'.''\'
      
      set -o noclobber append_history share_history

      test -e "~/.iterm2_shell_integration.zsh" && source "~/.iterm2_shell_integration.zsh" || true
      
      if [ "$(uname 2> /dev/null)" = "Darwin" ]; then
        #colima status 2>/dev/null || ( nohup colima start & ) >/dev/null 2>&1
	pgrep -q openvpn || ( pushd ~/otm-vpn ; nohup sudo -C 20 openvpn --config otm.ovpn --auth-user-pass <(gpg -qd ~/otm-vpn/vpn_creds.txt.gpg) & ; popd ) >/dev/null 2>&1
      fi

      function generate () { gopass generate -s -p $1 $((RANDOM % 14 + 45)) }

      [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
    '';

   plugins = with pkgs; [
      {
        name = "zsh-autopair";
        src = zsh-autopair;
        file = "share/zsh/zsh-autopair/autopair.zsh";
      }
      {
        name = "zsh-fzf-tab";
        src = zsh-fzf-tab;
        file = "share/fzf-tab/fzf-tab.zsh";
      }
      {
        name = "zsh-fast-syntax-highlighting";
	src = zsh-fast-syntax-highlighting;
	file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh";
      }
      {
        name = "zsh-powerlevel10k";
        src = zsh-powerlevel10k;
	file = "share/zsh-powerlevel10k/powerlevel10k.zsh-theme";
      }
      {
        name = "zsh-history-substring-search";
	src = zsh-history-substring-search;
	file = "share/zsh-history-substring-search/zsh-history-substring-search.zsh";
      }
      {
        name = "forgit";
        src = fetchFromGitHub {
          owner = "wfxr";
          repo = "forgit";
          rev = "810735294107ef1b1de66cf1cdfc358fc14049ac";
          sha256 = "11mydkl8psic57qzkzyjlff9wl6inwx9hn3a0vqyfr78pv6vk23y";
        };
        file = "forgit.plugin.zsh";
      }
      {
        name = "zsh-edit";
        src = fetchFromGitHub {
          owner = "marlonrichert";
          repo = "zsh-edit";
          rev = "17b17e5f32fc69349cb9474cf591d5c74e399cdc";
          sha256 = "0nvb7jril7in5b0279z25vmlc0karhagmfsxpjw1rzni5qpyak1s";
        };
        file = "zsh-edit.plugin.zsh";
      }
    ];
  };
}