Closed maxnordlund closed 7 years ago
This doesn't appear to strip the trailing newline. I ran a test at the command line and got different results vs the old code:
New code. Note the ⏎ at the end:
gln@gln-mbp ~/g/i/s/misc> printf "%b" (string join "\n" (iterm2_fish_prompt))
gln@gln-mbp ~/g/i/s/misc> ⏎
Old code, no ⏎:
gln@gln-mbp ~/g/i/s/misc> for line in (iterm2_fish_prompt)
set -q last_line; and echo $last_line
set last_line $line
end
gln@gln-mbp ~/g/i/s/misc>
The ⏎ character means no newline, see printf "no newline"
vs printf "newline\n"
. Which means the old code actually didn't strip the trailing newline…
However, fish handles that for you in your prompt, and I actually think it might strip the last newline if there is one. Try adding printf "\n"
, printf "\n\n"
etc to your fish_prompt.
Ah, you're right of course. Thanks for the clarification and the PR, this looks good.
This will go live on the next website update (when 3.0.15 goes into beta, most likely)
Not a problem, always happy to help 😄
This rewrites it into more idiomatic fish, and greatly simplifies it in the process.
I manually tested this on my machine, and it seems to work, even with multiline prompts and printf format strings. To reproduce what I have, just append
printf "\n\n%%s > \n"
to yourfish_prompt
function.Side note: It would be nice if this was part of the main app instead of here, which also would allow to ship the current version in the app. So you could
source /Applications/iTerm.app/Contents/integration/iterm.fish
or something similar.