-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbashrc.sh
More file actions
32 lines (27 loc) · 1.03 KB
/
Copy pathbashrc.sh
File metadata and controls
32 lines (27 loc) · 1.03 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
# Add this to .bashrc
# add ~/.local/bin to PATH if not in it
[[ ":${PATH}:" != *:"${HOME}/.local/bin":* ]] &&
export PATH="${HOME}/.local/bin:${PATH}"
bash_auto_comp() {
local mode="" prompt cmd_file
local -a result
# Optional: prepend a vi-mode indicator (for show-mode-in-prompt users).
# See console_codes(4) § ECMA-48 Select Graphic Rendition
# and bash(1) § PROMPTING
# mode="\[\e[1;38;5;8m\][i]\[\e[0m\]" # Uncomment and customize.
prompt="${mode}$(perl -pe 's/\\\[\\e\].*?\\\]//g' <<<"${PS1}")"
cmd_file="$(mktemp)" || return
trap 'rm -f "$cmd_file"' RETURN
bash_auto_comp.py "$cmd_file" "${prompt@P}"
if [[ -r "$cmd_file" ]]; then
mapfile -t result <"$cmd_file"
if ((${#result[@]} == 2)); then
READLINE_POINT="${result[0]}"
READLINE_LINE="${result[1]}"
fi
fi
}
# Bind to Alt-M (Esc M) by default
bind -m vi-command -x '"\em": bash_auto_comp'
bind -m vi-insert -x '"\em": bash_auto_comp'
bind -m emacs -x '"\em": bash_auto_comp'