Skip to content

Commit

Permalink
wrap tmux-jump and bind it to a key
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Jun 2, 2020
1 parent d2c7058 commit 38db05c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
7 changes: 5 additions & 2 deletions dotfiles/tmux.nix
@@ -1,5 +1,7 @@
{ pkgs, lib, ... }: {
home.packages = [ (pkgs.callPackage ../pkgs/tmux-session { }) ];
{ pkgs, lib, ... }:
let tmux-session = pkgs.callPackage ../pkgs/tmux-session { };
in {
home.packages = [ tmux-session ];

programs.tmux = {
enable = true;
Expand All @@ -19,6 +21,7 @@
# 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 j split-window -h ${tmux-session}/bin/tmux-jump
# get rid of the half-second escape time for kakoune's escape key
set -sg escape-time 25
Expand Down
11 changes: 1 addition & 10 deletions dotfiles/zsh/jump.zsh
Expand Up @@ -10,13 +10,4 @@ jump() {

alias j=jump

tmux_jump() {
BASE="$HOME/code"
SELECTED=$(find "$BASE" -mindepth 2 -maxdepth 2 -type d | sed "s|$BASE/||g" | fzf --tiebreak=end --select-1 --query="$1")

if [[ "$?" != 0 ]]; then echo "cancelling!"; return 1; fi

tmux-session "$BASE/$SELECTED"
}

alias t=tmux_jump
alias t=tmux-jump
10 changes: 9 additions & 1 deletion pkgs/tmux-session/default.nix
Expand Up @@ -3,11 +3,19 @@
with nixpkgs;
stdenv.mkDerivation {
name = "tmux-session";

src = ./.;
buildInputs = [ pkgs.makeWrapper ];

installPhase = ''
mkdir -p $out/bin
cp ./tmux-session $out/bin/tmux-session
wrapProgram $out/bin/tmux-session --prefix PATH : ${
pkgs.lib.makeBinPath [ tmux ]
}
cp ./tmux-jump $out/bin/tmux-jump
wrapProgram $out/bin/tmux-jump --prefix PATH : ${
pkgs.lib.makeBinPath [ findutils fzf ]
}
'';
}
10 changes: 10 additions & 0 deletions pkgs/tmux-session/tmux-jump
@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail

QUERY="${1:-}"
BASE="$HOME/code"
SELECTED=$(find "$BASE" -mindepth 2 -maxdepth 2 -type d | sed "s|$BASE/||g" | fzf --tiebreak=end --select-1 --query="$QUERY")

if [[ "$?" != 0 ]]; then echo "cancelling!"; return 1; fi

tmux-session "$BASE/$SELECTED"

0 comments on commit 38db05c

Please sign in to comment.