-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdot_bashrc
More file actions
92 lines (84 loc) · 3.49 KB
/
Copy pathdot_bashrc
File metadata and controls
92 lines (84 loc) · 3.49 KB
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
# If not running interactively, don't do anything (leave this at the top of this file)
[[ $- != *i* ]] && return
# Stock bits worth keeping — this file replaces a distro .bashrc wholesale, and
# on non-Omarchy hosts nothing else sets them.
HISTCONTROL=ignoreboth
HISTSIZE=10000
HISTFILESIZE=50000
shopt -s histappend checkwinsize
# Glob all files in ~/.config/bash/
shopt -s nullglob
for f in "$HOME"/.config/bash/*.sh; do
[[ -r "$f" ]] && source "$f"
done
shopt -u nullglob
# TODO: Delete when omarchy has fixed issue that sleep is needed before "c" command
tdl ()
{
[[ -z $1 ]] && {
echo "Usage: tdl <c|cx|codex|other_ai> [<second_ai>]";
return 1
};
[[ -z $TMUX ]] && {
echo "You must start tmux to use tdl.";
return 1
};
local current_dir="${PWD}";
local editor_pane ai_pane ai2_pane;
local ai="$1";
local ai2="$2";
editor_pane="$TMUX_PANE";
tmux rename-window -t "$editor_pane" "$(basename "$current_dir")";
tmux split-window -v -p 15 -t "$editor_pane" -c "$current_dir";
ai_pane=$(tmux split-window -h -p 30 -t "$editor_pane" -c "$current_dir" -P -F '#{pane_id}');
if [[ -n $ai2 ]]; then
ai2_pane=$(tmux split-window -v -t "$ai_pane" -c "$current_dir" -P -F '#{pane_id}');
tmux send-keys -t "$ai2_pane" "$ai2" C-m;
fi;
sleep 0.5
tmux send-keys -t "$ai_pane" "$ai" C-m;
tmux send-keys -t "$editor_pane" "$EDITOR ." C-m;
tmux select-pane -t "$editor_pane"
}
# Zoxide dir jump widget (multiplexer-independent; replaces tmux popup C-j).
# cd happens in THIS shell via bind -x, so it works under herdr, tmux, or bare terminal.
# Print `cd <dir>` (does not cd itself). The keybinding expands and runs it,
# so the dynamic prompt refreshes and the visible command is a clean `cd /path`.
# Prefers television (tv); falls back to fzf, which is what the servers have.
__zjump_cmd() {
local dir list
list="$(
zoxide query -l \
| while IFS= read -r d; do
git -C "$d" rev-parse --show-toplevel 2>/dev/null || printf '%s\n' "$d"
done \
| awk '!seen[$0]++'
)"
if command -v tv >/dev/null 2>&1; then
dir="$(printf '%s\n' "$list" \
| tv --source-command='cat' --source-display='{}' --source-output='{}' \
--no-remote --no-help-panel \
--input-header='Jump to directory' --input-prompt='zoxide> ' \
--preview-command='eza --color=always --icons=always -la {}' \
--preview-header='{}' --preview-border=rounded \
--results-border=rounded --input-border=rounded)" || return 0
else
dir="$(printf '%s\n' "$list" \
| fzf --prompt='zoxide> ' --height=40% --reverse \
--preview='ls -la {}' --preview-window=right:50%)" || return 0
fi
[ -n "$dir" ] && printf 'cd %q' "$dir"
}
# Binding it without a picker installed gives a key that silently does nothing.
if command -v zoxide >/dev/null 2>&1 \
&& { command -v tv >/dev/null 2>&1 || command -v fzf >/dev/null 2>&1; }; then
# emacs keymap: clear line, insert `__zjump_cmd` substitution, shell-expand it
# in place (runs the picker, replaces line with `cd /path`), then accept-line.
bind -m emacs-standard '"\C-o": "\C-e\C-u`__zjump_cmd`\e\C-e\C-m"'
# vi mode (~/.inputrc: set editing-mode vi): toggle to emacs, run, toggle back.
bind -m emacs-standard '"\C-z": vi-editing-mode'
bind -m vi-command '"\C-z": emacs-editing-mode'
bind -m vi-insert '"\C-z": emacs-editing-mode'
bind -m vi-command '"\C-o": "\C-z\C-o\C-z"'
bind -m vi-insert '"\C-o": "\C-z\C-o\C-z"'
fi