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

[ENH] - Cleanup terminal prompt #1157

Closed
dharhas opened this issue Mar 11, 2022 · 11 comments · Fixed by #1143 or #1363
Closed

[ENH] - Cleanup terminal prompt #1157

dharhas opened this issue Mar 11, 2022 · 11 comments · Fixed by #1143 or #1363
Assignees
Labels
type: enhancement 💅🏼 New feature or request

Comments

@dharhas
Copy link
Member

dharhas commented Mar 11, 2022

Feature description

When opening a terminal in JupyterLab the prompt could do with some cleanup.

dharhas@quansight.com@jupyter-dharhas-40quansight-2ecom:~$

Does jupyter-dharhas-40quansight-2ecom have any significance. If not we should just use

dharhas@quansight.com:~$ as the prompt

Also, why is /opt/conda/condabin/conda be printed twice

We should also consider other things for a nice terminal prompt, i.e. git-prompt integration

image

Value and/or benefit

A clean prompt greatly enhances the usability of the terminal.

Anything else?

No response

@dharhas dharhas added the type: enhancement 💅🏼 New feature or request label Mar 11, 2022
@pierrotsmnrd
Copy link
Contributor

This is a point I reported a few months ago when I collected the users' feedbacks.
What the users expect are :

  • the current directory
  • the current conda environment
  • the current git branch

Example inspired from my own zsh :

psimonard@quansight.com:~/earthquakes/data
(current_env) > $                                                                        [my_git_branch]

@costrouc
Copy link
Member

@dharhas this is resolved in #1143 I'm going to link this PR to this issue. We've been waiting to merge that PR since we've had a feature freeze for 0.4.

@dharhas
Copy link
Member Author

dharhas commented Mar 11, 2022

I like @pierrotsmnrd suggestion for what the prompt should show. Does #1143 fix that?

@costrouc
Copy link
Member

costrouc commented Mar 11, 2022

@dharhas currently #1143 fixes the issue with "/opt/conda/condabin..." being printed.

Do we have a PS1 prompt that should be used @pierrotsmnrd? It needs to be bash compatible. All I would need to do then is add the PS1 to the file and it should be available.

@viniciusdc
Copy link
Contributor

viniciusdc commented Mar 18, 2022

@dharhas currently #1143 fixes the issue with "/opt/conda/condabin..." being printed.

Do we have a PS1 prompt that should be used @pierrotsmnrd? It needs to be bash compatible. All I would need to do then is add the PS1 to the file and it should be available.

Hi @costrouc @dharhas, I was not able to generate a working example totally similar to what @pierrotsmnrd proposed, but I made this one
image
In theory, when installing conda the base environment should be added to it automatically to the left side (there is this script if needed as well)

The above PS1:

PS1='\[\e[0m\][\[\e[0m\]$(git branch 2>/dev/null | grep '"'"'^*'"'"' | colrm 1 2)\[\e[0m\]] \[\e[0m\]\u\[\e[0m\]:\[\e[0m\]\w\n \[\e[0m\]> \[\e[0m\]\$ \[\e[0m\]'
  • Some facts, as we are adding the git branch by a command, if there is no git repo in the working directory the end result of the prompt will be [ ] user:dir. So, to avoid that we can import the git PS1 file config and get the desired behavior with
source /usr/lib/git-core/git-sh-prompt
PS1='$(__git_ps1 "[%s]") \u\[\e[0m\]:\[\e[0m\]\w\n \[\e[0m\]> \[\e[0m\]\$ \[\e[0m\]'

Adding conda env by looking at echo $CONDA_PROMPT_MODIFIER:

source /usr/lib/git-core/git-sh-prompt
export PS1=' $(__git_ps1 "[%s] ")\u\[\e[0m\]:\[\e[0m\]\w \n $(echo $CONDA_PROMPT_MODIFIER) \[\e[0m\]> \[\e[0m\]\$ \[\e[0m\]'

image

@pierrotsmnrd
Copy link
Contributor

pierrotsmnrd commented Mar 20, 2022

Hi everyone

I wasn't able to find a ready-to-use PS1, my prompt uses the Bureau Theme of zsh : https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/bureau.zsh-theme

I hope this helps.

@dharhas
Copy link
Member Author

dharhas commented Jun 30, 2022

@costrouc @viniciusdc is this actually fixed? As far as I can tell, the issue was closed without the prompt actually being fixed OR there is no active deployment with the fix in place. qhub-beta still shows the old ugly bash prompt.

dharhas@quansight.com@jupyter-dharhas-40quansight-2ecom:~/

@dharhas dharhas reopened this Jun 30, 2022
@viniciusdc
Copy link
Contributor

@costrouc @viniciusdc is this actually fixed? As far as I can tell, the issue was closed without the prompt actually being fixed OR there is no active deployment with the fix in place. qhub-beta still shows the old ugly bash prompt.

dharhas@quansight.com@jupyter-dharhas-40quansight-2ecom:~/

Hi, @dharhas the prompt configuration is currently set in here, if I know what we would like to see I can make the necessary changes.

The clean up of the terminal logs, should have been fixed with a certain PR, c.c @costrouc here

@dharhas
Copy link
Member Author

dharhas commented Jun 30, 2022

@viniciusdc your proposal from 3 comments above is good enough for now. Please do a PR for that. We can tweak again later.

@dharhas
Copy link
Member Author

dharhas commented Jul 6, 2022

@viniciusdc A clean way to get a nice prompt is to use

https://github.com/magicmonty/bash-git-prompt

We would need to vendor the script and the folder

git clone https://github.com/magicmonty/bash-git-prompt.git ~/.bash-git-prompt --depth=1

Then add the following to .bashrc

GIT_PROMPT_THEME=Solarized
source $HOME/.bash-git-prompt/gitprompt.sh

We can add the conda env by setting the changeps1 flag in conda (this can also be set in the condarc file)

conda config --set changeps1 True

This is more changes that I'm comfortable making since I'm not sure the best way to vendor code.

@dharhas
Copy link
Member Author

dharhas commented Jul 6, 2022

two other things to change in the .bashrc

  • remove the comment on #force_color_prompt=yes
  • add alias ls='ls --color=auto'

@dharhas dharhas mentioned this issue Jul 6, 2022
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement 💅🏼 New feature or request
Projects
None yet
4 participants