aboutsummaryrefslogtreecommitdiff
path: root/programs/bash.nix
diff options
context:
space:
mode:
Diffstat (limited to 'programs/bash.nix')
-rw-r--r--programs/bash.nix41
1 files changed, 40 insertions, 1 deletions
diff --git a/programs/bash.nix b/programs/bash.nix
index 9ad3217..2a3cb97 100644
--- a/programs/bash.nix
+++ b/programs/bash.nix
@@ -23,7 +23,6 @@
23 rless = "less -r"; 23 rless = "less -r";
24 tmux = "tmux -u"; 24 tmux = "tmux -u";
25 tree = "tree -C"; 25 tree = "tree -C";
26 vim = "nvim";
27 tb = "nc termbin.com 9999"; 26 tb = "nc termbin.com 9999";
28 n = "j"; 27 n = "j";
29 28
@@ -35,6 +34,7 @@
35 gl = "git log -p --abbrev-commit --pretty=medium"; 34 gl = "git log -p --abbrev-commit --pretty=medium";
36 glo = "git log --pretty=oneline --abbrev-commit"; 35 glo = "git log --pretty=oneline --abbrev-commit";
37 gst = "git status --short"; 36 gst = "git status --short";
37 gwls = "git worktree list";
38 }; 38 };
39 39
40 shellOptions = [ 40 shellOptions = [
@@ -78,6 +78,45 @@
78 export PS1="\n\001\e[0;36m\002λ\001\e[0m\002 "; 78 export PS1="\n\001\e[0;36m\002λ\001\e[0m\002 ";
79 export PS2="> "; 79 export PS2="> ";
80 80
81 # git functions
82
83 function fuzzy_worktree () {
84 # 1: function that operates on the fzf result
85 # 2: an optional query
86 query="''${2:- }"
87 out=$(
88 set -o pipefail && \
89 git worktree list | \
90 fzf --min-height=15 \
91 --preview-window=up,10 \
92 --preview='git log --color=always -n10 --oneline {2}' \
93 --cycle -1 \
94 -q "$query" | \
95 awk '{print $1}'
96 )
97 [ $? -eq 0 ] && echo "$out" && $1 $out
98 }
99
100 function gwj () {
101 fuzzy_worktree __cd $@
102 }
103
104 function gwa () {
105 git worktree add "$1" && cd "$1"
106 }
107
108 function gwrm () {
109 fuzzy_worktree __rm $@
110 }
111
112 function __cd() {
113 cd "$1"
114 }
115
116 function __rm() {
117 git worktree remove "$1"
118 }
119
81 ''; 120 '';
82 121
83 }; 122 };