JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.41k stars 2.38k forks source link

When Oh My Posh is enabled the ZSH history is ignored #645

Closed MarcinGil closed 3 years ago

MarcinGil commented 3 years ago

Prerequisites

Description

Using ZSH in Ubuntu my terminals are started with clean history even though a huge .zhistory exists.

Environment

Steps to Reproduce

  1. Install and configure Oh My Posh in Linux/ZSH as in manual
  2. Add startup to .zshrc eval "$(oh-my-posh --init --shell zsh --config ~/.poshthemes/powerlevel10k_classic.omp.json)"
  3. Observe history is clear upon startup of Konsole
  4. File .zsh_history exists and is non-empty but also not updated with the latest commands

Expected behavior: [What you expected to happen]

History works fine

Actual behavior: [What actually happened]

ZSH history file is ignored and not updated. New commands are not added there and the shell is also unable to look through the history.

image

When using Oh My ZSH (and Powerlevel 10k theme) everything works fine

image

JanDeDobbeleer commented 3 years ago

@MarcinGil I'm on macOS using ZSH and can't reproduce this. I have the same invocation and oh-my-posh doesn't really do much other than set the prompt, every other behaviour should stay the same. Are you certain there's nothing in your setup that influences this?

EDIT: hold it, it seems the latest version does ruin this. I was on 3.120.1 before. I'll check.

lnu commented 3 years ago

seems to work with the latest version(wsl ubuntu): image

I also use these plugins: plugins=(common-aliases git zsh-autosuggestions zsh-syntax-highlighting)

And autosuggestions works based on the history.

JanDeDobbeleer commented 3 years ago

@lnu it worked for me until I upgraded. So I can reproduce this. I'll try to figure out a fix (but I'm afraid we could be duplicating history in that case).

lnu commented 3 years ago

@JanDeDobbeleer how did you reproduce it? I tried my local build and I also downloaded the latest version and in wsl at least it works as expected. Is it a link to a specific configuration ?

PS: if I don't use oh-my-zsh I can reproduce it. But in that case, you have ton configure zsh history in the .zshrc manually. Like this:

SAVEHIST=10
HISTFILE=~/.zsh_history
MarcinGil commented 3 years ago

@lnu for me this is enough to reproduce image

PS: I'll try your solution to manually specify history file.

lnu commented 3 years ago

So you don't use oh-my-zsh and history does not work? but when you user oh-my-zsh it works because history is configured automatically. Can you try to add this in your .zshrc:

SAVEHIST=10
HISTFILE=~/.zsh_history

Without those lines I can reproduce your issue but it works when they're added to .zshrc.

MarcinGil commented 3 years ago

@lnu @JanDeDobbeleer It works with manual setting of the history file

image

PS. I didn't know you could actually have OhMyZSH and OhMyPosh together.

lnu commented 3 years ago

Ohmyzsh does more than just setting the prompt. You can mix both to get all the plugins from ohmyzsh and only use ohmyposh to override th prompt.

JanDeDobbeleer commented 3 years ago

@lnu HISTFILE is set for me, I wonder if it's only the SAVEHIST part.

lnu commented 3 years ago

https://unix.stackexchange.com/questions/389881/history-isnt-preserved-in-zsh https://www.soberkoder.com/better-zsh-history/

MarcinGil commented 3 years ago

https://unix.stackexchange.com/questions/389881/history-isnt-preserved-in-zsh

Argh! Simply means I relied too much on magic as I usually configure Zsh and OhMyZsh together. Thank you for insight @lnu !

MarcinGil commented 3 years ago

@JanDeDobbeleer I believe we can close the issue as won't fix. Sorry for taking your time guys.

JanDeDobbeleer commented 3 years ago

@MarcinGil it was our pleasure! Learned something today thx to @lnu 👍🏻💪🏻

github-actions[bot] commented 6 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.