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

Moving up and down in the command history will keep previous commands characters in the prompt #4587

Open
RNBermudez opened this issue Nov 9, 2022 · 1 comment
Labels
🐛 bug Something isn't working as expected.

Comments

@RNBermudez
Copy link

Bug Report

Current Behavior

Going back in the commands history with the up arrow key, and then going back to the latest commands will keep characters from previous commands in front of the prompt.

Steps to reproduce:

  1. enter a command (for example ls -la | grep foo
  2. go back in the commands history with the up arrow
  3. go all the way forward to the prompt with the down arrow
  4. characters will be "stuck" in the prompt

Expected Behavior

The prompt should remain unchanged/clean when going back and forward in the command history.

Additional context/Screenshots

https://i.imgur.com/F9zFjKi.gif

Possible Solution

None that I have found

Environment

  • Starship version:
starship 1.11.0
branch:master
commit_hash:
build_time:2022-10-15 01:51:42 +00:00
build_env:rustc 1.64.0 (a55dd71d5 2022-09-19),stable-x86_64-pc-windows-msvc
  • Shell type: bash (Git-Bash for Windows)
  • Shell version:
git version 2.37.1.windows.1
GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
  • Terminal emulator: Windows Terminal
  • Operating system: Windows 10

Relevant Shell Configuration

#!/bin/bash

# Functions
bdec() {
    echo -n "$1" | base64 -d
}

# Kubernetes
export KUBE_EDITOR='code --wait'
alias k=kubectl

# Launch Starship propt
eval "$(starship init bash)"

Starship Configuration

# Get editor completions based on the config schema
"$schema" = 'https://starship.rs/config-schema.json'

# Inserts a blank line between shell prompts
add_newline = true

# Change the default prompt format
format = """\
$username at $hostname\
$directory\
$aws\
$kubernetes\
$all\
$line_break\
$time\
$character"""

[aws]
force_display = true
symbol = "☁️ "
format = 'on [$symbol($profile )(\($region\) )(\[$duration\] )]($style)'
disabled = false

[azure]
disabled = true

[battery]
disabled = true

[buf]
disabled = true

[bun]
disabled = true

[c]
disabled = true

[character]
success_symbol = '[](bright-cyan)'
error_symbol = "[](bright-red)"

[cmake]
disabled = true

[cobol]
disabled = true

[cmd_duration]
min_time = 1_000
show_milliseconds = true
style = "fg:bright-yellow"
format = '[\[took ](fg:yellow)[$duration]($style)[\]](fg:yellow)'

[conda]
disabled = true

#[container]

[crystal]
disabled = true

[daml]
disabled = true

[dart]
disabled = true

[deno]
disabled = true

[directory]
truncation_length = 5
truncation_symbol = "…/"
truncate_to_repo = true
use_os_path_sep = false
home_symbol = "~"
read_only = ""
style = "fg:bright-purple"
read_only_style = "fg:red"
format = 'in [$path]($style)[$read_only]($read_only_style) '

#[docker_context]

[dotnet]
disabled = true

[elixir]
disabled = true

[elm]
disabled = true

[env_var]
disabled = true

[erlang]
disabled = true

[fill]
disabled = true

[gcloud]
disabled = true

[git_branch]
symbol = ""
truncation_length = 10
truncation_symbol = "…/"
style = "fg:bright-green"
format = "on [$symbol$branch]($style) "

#[git_commit]

#[git_metrics]

#[git_state]

# [git_status]
# format = '[(\($all_status$ahead_behind\))]($style) '
# style = "bold green"
# conflicted = "🏳"
# up_to_date = " "
# untracked = " "
# ahead = "⇡${count}"
# diverged = "⇕⇡${ahead_count}⇣${behind_count}"
# behind = "⇣${count}"
# stashed = " "
# modified = " "
# staged = '[++\($count\)](green)'
# renamed = "襁 "
# deleted = " "

[golang]
disabled = true

[haskell]
disabled = true

#[helm]

[hostname]
ssh_only = false
format = "[$ssh_symbol](fg:bright-blue)[$hostname](fg:bright-cyan) "
disabled = false

[java]
disabled = true

#[jobs]

[julia]
disabled = true

[kotlin]
disabled = true

[kubernetes]
symbol = ""
style = "fg:bright-yellow"
format = '[\($context( \($namespace\))\)]($style) '
disabled = false

[line_break]
disabled = false

[localip]
disabled = true

[lua]
disabled = true

#[memory_usage]

[meson]
disabled = true

[hg_branch]
disabled = true

[nim]
disabled = true

[nix_shell]
disabled = true

[nodejs]
disabled = true

[ocaml]
disabled = true

[openstack]
disabled = true

# The package module is shown when the current directory is the repository for a package, and shows its current version.
[package]
disabled = true

[perl]
disabled = true

[php]
disabled = true

[pulumi]
disabled = true

[purescript]
disabled = true

#[python]

[rlang]
disabled = true

[raku]
disabled = true

[red]
disabled = true

[ruby]
disabled = true

[rust]
disabled = true

[scala]
disabled = true

# The shell module shows an indicator for currently used shell.
[shell]
disabled = true

# The shlvl module shows the current SHLVL ("shell level") environment variable, if it is set to a number and meets or exceeds the specified threshold.
[shlvl]
disabled = true

[singularity]
disabled = true

[spack]
disabled = true

#[status]

#[sudo]

[swift]
disabled = true

#[terraform]

[time]
use_12hr = false
style = "fg:bright-black"
format = '[$time]($style) '
disabled = false

[username]
style_user = "fg:bright-cyan"
style_root = "fg:red"
format = "[$user]($style)"
show_always = true

[vagrant]
disabled = true

[vlang]
disabled = true

[vcsh]
disabled = true

[zig]
disabled = true
@RNBermudez RNBermudez added the 🐛 bug Something isn't working as expected. label Nov 9, 2022
@ucodery
Copy link
Sponsor

ucodery commented Jan 17, 2023

This is interesting, I have had the same issue but never before connected it to Starship. I thought it was an issue with how I have readline setup, especially as I get the same behaviour when Starship doesn't display (exact same behaviour when in an interactive Python session launched by my bash).

I don't really have any further insight into this, but I did implement a workaround, which is this line in my .inputrc

"\C-f": redraw-current-line

which is equivalent to running this bash command, if you don't use .inputrc,

bind '"\C-f": redraw-current-line'

which just means that pressing ctrl-f will redraw the input line, and the phantom characters go away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working as expected.
Projects
None yet
Development

No branches or pull requests

2 participants