skylerlee / zeta-zsh-theme

Another :star: theme for oh-my-zsh
MIT License
223 stars 71 forks source link

get_space function #1

Closed dennym closed 8 years ago

dennym commented 8 years ago

Hey there, ist not an issue more a question. Could you give an explanation to https://github.com/skylerlee/zeta-zsh-theme/blob/master/zeta.zsh-theme#L84

I use a self modified agnoster theme and have the input on the newline and can't use RPROMPT directly. So I managed to use a spacing function similar to yours and it already scales fine with window resizing. Biggest Problem is the resizing when the PROMPT changes. Like the pwd/git info gets longer or shorter.

So yeah a small intro to your get space would be nice since its pretty hard to decipher.

best regards denym_

skylerlee commented 8 years ago

@dennym Well, in fact, I referred the bureau theme bureau.zsh-theme#L94 implementation.

What the line 86-87 do is counting the visible chars among the prompt string, because the ANSI escape code (eg. 0x1B[31m) also takes space. I don't know much about the details. But the following links might help.

http://stackoverflow.com/questions/10564314/count-length-of-user-visible-string-for-zsh-prompt http://linux.die.net/man/1/zshexpn

For the case which pwd or git info contained in prompt, I don't think there will be any problems if it is executed in precmd hook. But notice that the previous output won't change with window size.

Hope this helps.

dennym commented 8 years ago

thanks for response, will have a look on this.