Skip to content

Commit

Permalink
pull out lazygit window snippet to a separate package
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jun 3, 2020
1 parent 38db05c commit 1dcff90
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
8 changes: 5 additions & 3 deletions dotfiles/tmux.nix
@@ -1,7 +1,9 @@
{ pkgs, lib, ... }:
let tmux-session = pkgs.callPackage ../pkgs/tmux-session { };
let
tmux-session = pkgs.callPackage ../pkgs/tmux-session { };
lazygit-window = pkgs.callPackage ../pkgs/lazygit-window { };
in {
home.packages = [ tmux-session ];
home.packages = [ tmux-session lazygit-window ];

programs.tmux = {
enable = true;
Expand All @@ -20,7 +22,7 @@ in {
bind-key -n C-l select-pane -R
# quickly open CLI tools
bind h run-shell "tmux switch-client -t :lazygit || tmux new-window -k -n 'lazygit' -c '#{pane_current_path}' ${pkgs.lazygit}/bin/lazygit"
bind h run-shell "${lazygit-window}/bin/lazygit-window"
bind j split-window -h ${tmux-session}/bin/tmux-jump
# get rid of the half-second escape time for kakoune's escape key
Expand Down
2 changes: 0 additions & 2 deletions dotfiles/zsh.nix
Expand Up @@ -42,8 +42,6 @@ in {
RPROMPT=
eval $(${pkgs.thefuck}/bin/thefuck --alias heck)
alias g=lazygit
'' + extraInitExtra;

history = {
Expand Down
2 changes: 2 additions & 0 deletions dotfiles/zsh/git.zsh
Expand Up @@ -7,3 +7,5 @@ checkout_branch() {
}

alias co=checkout_branch

alias g=lazygit-window
17 changes: 17 additions & 0 deletions pkgs/lazygit-window/default.nix
@@ -0,0 +1,17 @@
{ sources ? import ../../nix/sources.nix, nixpkgs ? import sources.nixpkgs { }
}:
with nixpkgs;
stdenv.mkDerivation {
name = "lazygit-window";
src = ./.;
buildInputs = [ pkgs.makeWrapper ];

installPhase = ''
mkdir -p $out/bin
cp ./lazygit-window.sh $out/bin/lazygit-window
wrapProgram $out/bin/lazygit-window --prefix PATH : ${
pkgs.lib.makeBinPath [ tmux lazygit ]
}
'';
}

2 changes: 2 additions & 0 deletions pkgs/lazygit-window/lazygit-window.sh
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
tmux switch-client -t :lazygit >/dev/null 2>&1 || tmux new-window -k -n 'lazygit' -c '#{pane_current_path}' lazygit
2 changes: 2 additions & 0 deletions pkgs/tmux-session/default.nix
Expand Up @@ -2,6 +2,8 @@
}:
with nixpkgs;
stdenv.mkDerivation {
# inspired by one of Stöffel's keybindings at
# https://github.com/stoeffel/.dots/blob/master/tmux/keybindings.conf
name = "tmux-session";
src = ./.;
buildInputs = [ pkgs.makeWrapper ];
Expand Down

0 comments on commit 1dcff90

Please sign in to comment.