Move prompt_context to a fish function

Include some optimizations, increase the speed by 4 times