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

line editing mode for bash #5758

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/init/starship.bash
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ starship_preexec() {

# Will be run before the prompt is drawn
starship_precmd() {
KEYMAP="$(bind -V 2> /dev/null | grep keymap)"
STARSHIP_KEYMAP="viins"
if [[ "$KEYMAP" =~ "vi" ]] && [[ ! "$KEYMAP" =~ "vi-insert" ]]; then
STARSHIP_KEYMAP="vicmd"
fi

# Save the status, because commands in this pipeline will change $?
STARSHIP_CMD_STATUS=$? STARSHIP_PIPE_STATUS=(${PIPESTATUS[@]})
if [[ ${BLE_ATTACHED-} && ${#BLE_PIPESTATUS[@]} -gt 0 ]]; then
Expand Down Expand Up @@ -69,7 +75,7 @@ starship_precmd() {
eval "$_PRESERVED_PROMPT_COMMAND"
fi

local -a ARGS=(--terminal-width="${COLUMNS}" --status="${STARSHIP_CMD_STATUS}" --pipestatus="${STARSHIP_PIPE_STATUS[*]}" --jobs="${NUM_JOBS}")
local -a ARGS=(--terminal-width="${COLUMNS}" --status="${STARSHIP_CMD_STATUS}" --pipestatus="${STARSHIP_PIPE_STATUS[*]}" --jobs="${NUM_JOBS}" --keymap="$STARSHIP_KEYMAP")
# Prepare the timer data, if needed.
if [[ -n "${STARSHIP_START_TIME-}" ]]; then
STARSHIP_END_TIME=$(::STARSHIP:: time)
Expand Down
1 change: 1 addition & 0 deletions src/modules/character.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
// The result: in non-vi fish, keymap is always reported as "insert"
let mode = match (&context.shell, keymap) {
(Shell::Fish, "default")
| (Shell::Bash, "vicmd")

Check warning on line 39 in src/modules/character.rs

View check run for this annotation

Codecov / codecov/patch

src/modules/character.rs#L39

Added line #L39 was not covered by tests
| (Shell::Zsh, "vicmd")
| (Shell::Cmd | Shell::PowerShell, "vi") => ShellEditMode::Normal,
(Shell::Fish, "visual") => ShellEditMode::Visual,
Expand Down