Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] inputrc and right prompt #111

Merged
merged 5 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions dotfiles_template/shell/.inputrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
$if Bash
"\C-l": redraw-current-line
"\e\C-j": accept-line
"\C-j": "\C-l\e\C-j"
"\C-m": "\C-l\e\C-j"
"\C-l": clear-screen
"\C-b": redraw-current-line
"\e\C-j": accept-line
"\C-j": "\C-b\e\C-j"
"\C-m": "\C-b\e\C-j"
"\C-p":previous-history
"\C-n":next-history
"\C-a.":beginning-of-line
"\C-e.":end-of-line
"\C-l":clear-screen
$endif
31 changes: 19 additions & 12 deletions shell/bash/init.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
if [[ "$(ps -p $$ -ocomm=)" =~ (bash$) ]]; then
__right_prompt() {
RIGHT_PROMPT=""
[[ -n $RPS1 ]] && RIGHT_PROMPT=$RPS1 || RIGHT_PROMPT=$RPROMPT
if [[ -n $RIGHT_PROMPT ]]; then
n=$((COLUMNS - ${#RIGHT_PROMPT}))
printf "%${n}s$RIGHT_PROMPT\\r"
fi
}
export PROMPT_COMMAND="__right_prompt"
fi
#!/usr/bin/env bash
# Rigth prompt for bash definition
__right_prompt() {
RIGHT_PROMPT=""
[[ -n $RPS1 ]] && RIGHT_PROMPT=$RPS1 || RIGHT_PROMPT=$RPROMPT
if [[ -n $RIGHT_PROMPT ]]; then
n=$((COLUMNS - ${#RIGHT_PROMPT}))
printf "%${n}s$RIGHT_PROMPT\\r"
fi

if [[ -n "${THEME_COMMAND:-}" ]] && declare -F "${THEME_COMMAND:-}" &> /dev/null; then
"${THEME_COMMAND:-}"
fi
}

PATH=$(
IFS=":"
Expand Down Expand Up @@ -39,9 +42,13 @@ fi
for THEME_PATH in ${themes_paths[@]}; do
SLOTH_THEME="${SLOTH_THEME:-DOTLY_THEME}"
THEME_PATH="${THEME_PATH}/${SLOTH_THEME:-codely}.sh"
THEME_COMMAND=""
#shellcheck source=/dev/null
[ -f "$THEME_PATH" ] && . "$THEME_PATH" && break
[ -f "$THEME_PATH" ] && . "$THEME_PATH" && THEME_COMMAND="${PROMPT_COMMAND:-}" && break
done
# Now we know which theme we should use, so define right prompt
PROMPT_COMMAND="__right_prompt"
export THEME_COMMAND PROMPT_COMMAND

find {"${SLOTH_PATH:-${DOTLY_PATH:-}}","$DOTFILES_PATH"}"/shell/bash/completions/" -name "_*" -print0 -exec echo {} \; 2> /dev/null | xargs -0 -I _ echo _ | while read -r completion; do
[[ -z "$completion" ]] && continue
Expand Down
1 change: 1 addition & 0 deletions shell/bash/themes/codely.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
PROMPT_COMMAND="codely_theme"

MIDDLE_CHARACTER="◂"
Expand Down
1 change: 1 addition & 0 deletions shell/bash/themes/codelytv.sh
1 change: 1 addition & 0 deletions shell/zsh/init.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env zsh
#shellcheck disable=SC2148
reverse-search() {
local selected num
Expand Down