oh-my-fish / theme-dangerous

A feature-rich theme derived from budspencer without powerline font.
33 stars 8 forks source link

Strange errors appearing in terminal after install #2

Closed faceleg closed 9 years ago

faceleg commented 9 years ago

I'm getting the following output after installing the theme and cd-ing into a git repo:

❯ 2 ❯❯ ✔ ❯ expr: not a decimal number: '       0'                          ❮ ~ ❮
test: Missing argument at index 2

Is there something you know of that will fix this?

OS X 10.10 fish, version 2.2.0-115-gdeacec0 git version 2.4.6

tannhuber commented 9 years ago

Thanks for reporting this bug. It should be possible to fix it if you can reproduce it. I hope you can help me. First of all, can you change the fish_right_prompt function at the end of file fish_right_prompt.fish as follows:

function fish_right_prompt -d 'Write out the right prompt of the dangerous theme'
 #    echo -n -s (__dangerous_cmd_duration) (__dangerous_prompt_git_symbols) (__dangerous_prompt_pwd)
     echo -n -s (__dangerous_cmd_duration) (__dangerous_prompt_pwd)
     set_color normal
 end

and tell me whether the error message has gone?

faceleg commented 9 years ago

Hi @tannhuber thanks for the quick reply.

Your change make the error message go away

tannhuber commented 9 years ago

Then, can you paste the following line

echo "$git_status[1] + $git_status[2] + $git_status[3] + $git_status[4] + $git_status[5] + $git_status[6] + $git_stashed" > /tmp/fishprompt.log

before

if [ (expr $git_status[1] + $git_status[2] + $git_status[3] + $git_status[4] + $git_status[5] + $git_status[6] + $git_stashed) -ne 0 ]

? I think the line beginning with if has line number 116. After adding the new line, the additional line beginning with echo should have line number 116, while the if line number changes to 117.

Start a new shell, change into a git repository with changes and tell me the content of /tmp/fishprompt.log.

faceleg commented 9 years ago
❯ 3 ❯❯  develop ❯❯ ✔ ❯ more /tmp/fishprompt.log                                                                                                                                                                        ❮ ~/o/W/6/s/frontend ❮
0 + 0 + 1 + 0 + 0 + 0 +        0
tannhuber commented 9 years ago

It seems that wc produces formatted output (leading tab character) on Mac OS. Can you check with a simple command:

echo -n "" | wc -l

Does it print a tab character or any other whitespace in front of the 0?

tannhuber commented 9 years ago

If the assumption above is correct, try

    command git log --format="%gd" -g $argv 'refs/stash' -- ^ /dev/null | wc -l | tr -d '\t'

instead of

    command git log --format="%gd" -g $argv 'refs/stash' -- ^ /dev/null | wc -l

within function __dangerous_is_git_stashed (line 103). I'll push a bug fix if you tell me that everything is fine.

faceleg commented 9 years ago

If I replace line 103 with the line command git log --format="%gd" -g $argv 'refs/stash' -- ^ /dev/null | wc -l | tr -d '\t', I still get errors

tannhuber commented 9 years ago

What happens, if you replace the line by

command git log --format="%gd" -g $argv 'refs/stash' -- ^ /dev/null | wc -l | tr -d '[:space:]'

? If there're still errors, what's the output of

echo -n "" | wc -l

? Can you just enter the command in a shell and check whether there's whitespace in front of the 0?

faceleg commented 9 years ago

That seemed to work!

tannhuber commented 9 years ago

Thank you!

faceleg commented 9 years ago

No thank you! This is by far the most usable and attractive shell theme I've used