blob: d4a52f2b61d406f46861dc1f821076183bc67381 (
plain)
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
|
{ config
, pkgs
, ...
}:
{
programs.bash = {
enable = true;
historyControl = [ "erasedups" ];
historyFile = "\$HOME/.bash_history";
historyFileSize = 2000;
historyIgnore = [ "ls" "exit" "kill" ];
historySize = 1000;
shellAliases = {
"..." = "cd -- ../..";
"...." = "cd -- ../../..";
grep = "grep --color=auto";
l = "ls -CF";
la = "ls -A";
ll = "ls -alF";
ls = "ls -F --color=always";
o = "xdg-open";
rless = "less -r";
tmux = "tmux -u";
tree = "tree -C";
tb = "nc termbin.com 9999";
# git aliases
gb = "git branch -v";
gc = "git commit --verbose";
gd = "git diff --minimal";
gp = "git push";
gpf = "git push --force-with-lease";
gl = "git log -p --abbrev-commit --pretty=medium";
glo = "git log --pretty=oneline --abbrev-commit";
gst = "git status --short";
gwls = "git worktree list";
};
shellOptions = [
"histappend"
"autocd"
"globstar"
"checkwinsize"
"cdspell"
"dirspell"
"expand_aliases"
"dotglob"
"gnu_errfmt"
"histreedit"
"nocasematch"
];
sessionVariables = {
TERM = "alacritty";
EDITOR = "nvim";
MANPAGER = "nvim +Man!";
GPG_TTY = "\$(tty)";
};
initExtra = ''
export PATH=$PATH:"$HOME/scripts"
export PROMPT_COMMAND="tmux refresh-client -S &> /dev/null";
export PS1="\n\001\e[0;36m\002λ\001\e[0m\002 ";
export PS2="> ";
# git functions
function fuzzy_worktree () {
# 1: function that operates on the fzf result
# 2: an optional query
query="''${2:- }"
out=$(
set -o pipefail && \
git worktree list | \
fzf --min-height=15 \
--preview-window=up,10 \
--preview='git log --color=always -n10 --decorate --oneline {2}' \
--cycle -1 \
-q "$query" | \
awk '{print $1}'
)
[ $? -eq 0 ] && echo "$out" && $1 $out
}
function gwj () {
fuzzy_worktree __cd $@
}
function gwa () {
git worktree add "$1" && cd "$1"
}
function gwrm () {
fuzzy_worktree __rm $@
}
function __cd() {
cd "$1"
}
function __rm() {
git worktree remove "$1"
}
'';
};
}
|