Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow Username with spaces #1031

Closed
1 task done
aadi123 opened this issue Oct 9, 2021 · 12 comments · Fixed by #1034
Closed
1 task done

Allow Username with spaces #1031

aadi123 opened this issue Oct 9, 2021 · 12 comments · Fixed by #1034
Assignees
Labels
🐛 bug Something isn't working

Comments

@aadi123
Copy link

aadi123 commented Oct 9, 2021

Code of Conduct

  • I agree to follow this project's Code of Conduct

What happened?

A bug happened!

When I try to use Oh-my-posh-wsl, the theme does not work. That is because my windows username has a space, and it does not escape the space when evaluating the bash command.
Ex: Windows username: Aaditya Murthy should be Aaditya\ Murthy in the bash script.

Version

5.7.2

Theme

jandedobbeleer.omp.json

What OS are you seeing the problem on?

Windows

Which shell are you using?

bash

Relevant log output

export POSH_THEME="/home/aaditya/jandedobbeleer.omp.json"
export POWERLINE_COMMAND="oh-my-posh"
export CONDA_PROMPT_MODIFIER=false

TIMER_START="/tmp/${USER}.start.$$"

# some environments don't have the filesystem we'd expect
if [[ ! -d "/tmp" ]]; then
        TIMER_START="${HOME}/.${USER}.start.$$"
fi

PS0='$(/mnt/c/Users/Aaditya Murthy/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh-wsl --millis > "$TIMER_START")'

function _omp_hook() {
        local ret=$?

        omp_stack_count=$((${#DIRSTACK[@]} - 1))
        omp_elapsed=-1
        if [[ -f "$TIMER_START" ]]; then
                omp_now=$(/mnt/c/Users/Aaditya Murthy/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh-wsl --millis)
                omp_start_time=$(cat "$TIMER_START")
                omp_elapsed=$((omp_now-omp_start_time))
                rm -f "$TIMER_START"
        fi
        PS1="$(/mnt/c/Users/Aaditya Murthy/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh-wsl --config $POSH_THEME --shell bash --error $ret --execution-time $omp_elapsed --stack-count $omp_stack_count)"

        return $ret
}

if [ "$TERM" != "linux" ] && [ -x "$(command -v /mnt/c/Users/Aaditya Murthy/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh-wsl)" ] && ! [[ "$PROMPT_COMMAND" =~ "_omp_hook" ]]; then
        PROMPT_COMMAND="_omp_hook; $PROMPT_COMMAND"
fi

function _omp_runonexit() {
        [[ -f $TIMER_START ]] && rm -f "$TIMER_START"
}

trap _omp_runonexit EXIT

function export_poshconfig() {
        [ $# -eq 0 ] && { echo "Usage: $0 \"filename\""; return; }
        format=$2
        if [ -z "$format" ]; then
                format="json"
        fi
        /mnt/c/Users/Aaditya\ Murthy/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh-wsl --config $POSH_THEME --print-config --config-format $format > $1
}
@aadi123 aadi123 added the 🐛 bug Something isn't working label Oct 9, 2021
@aadi123
Copy link
Author

aadi123 commented Oct 9, 2021

The \ character I had to manually add in my bashrc

@JanDeDobbeleer
Copy link
Owner

@aadi123 if you import with eval "$(/mnt/c/Users/Aaditya\ Murthy/AppData/Local/Programs/oh-my-posh/bin/oh-my-posh-wsl --init --shell bash --config ~/jandedobbeleer.omp.json)" it should work out of the box. In the meantime I'll check if I can work around that.

@aadi123
Copy link
Author

aadi123 commented Oct 9, 2021

@JanDeDobbeleer Doing that still does not work, there are other places where it needs to be added as well.

@JanDeDobbeleer
Copy link
Owner

@aadi123 it's because we fetch the actual path, then replace and it's there that it's not escaped. Which is solvable at that moment. I'll try a workaround tomorrow.

@aadi123
Copy link
Author

aadi123 commented Oct 10, 2021

What about the config file? I am unable to use my windows config file for the same reason, is that my username has a space in it @JanDeDobbeleer . For example, i specify
--config /mnt/c/Users/Aaditya\ Murthy/jandedobeeler.omp.json
but
export POSH_THEME="/mnt/c/Users/Aaditya Murthy/jandedobbeleer.omp.json"
is showing up

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Oct 10, 2021

@aadi123 the config should be solvable by adding the correct path (with \ instead of ).

@aadi123
Copy link
Author

aadi123 commented Oct 10, 2021

@JanDeDobbeleer What's the ETA for the config file fix? Should be a fairly simple change?

@JanDeDobbeleer
Copy link
Owner

JanDeDobbeleer commented Oct 11, 2021

@JanDeDobbeleer What's the ETA for the config file fix? Should be a fairly simple change?

@aadi123 I have to admit, that sentence made me more than a little annoyed. First of all, never assume the time it takes to actually fix something. Secondly, we're not in a client/provider relationship here so you're nowhere near in a position to expect any ETA's. I know it might not have been the intent, but be mindful of how you talk to people going the extra mile daily to offer things you take for granted.

That said: #1038

@aadi123
Copy link
Author

aadi123 commented Oct 11, 2021

@JanDeDobbeleer I'm sorry, that was not the intent of the message. I appreciate all the hard work you've been putting into this project.

@JanDeDobbeleer
Copy link
Owner

@aadi123 thanks. Some days are more challenging for OSS maintainers than others, and this weekend for sure was like that.

Can you let me know if the latest change resolves the issue? I did a full manual validation and that seemed like the only way to get it to work consistently.

@aadi123
Copy link
Author

aadi123 commented Oct 11, 2021

Yup latest change fixes the issue!

Copy link

github-actions bot commented Apr 1, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 1, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants