Comments (14)
Sorry, I won't be adding fish support -- it would basically require everything to be to re-implemented from scratch. You can see details here #16
Again, sorry to disappoint you
from promptline.vim.
Would you implement fish support (e.g. a "fish" flag in :PromptlineSnapshot
) if I port all the generated shell code to fish?
from promptline.vim.
Sure! I would suggest we start with one slice, function __promptline_cwd
for example as it's the most often used one.
Could you port it to fish and share the code here? I will give some thought to what would be the best way to store the fish code in the repository.
from promptline.vim.
Ok, thanks! This implementation is only with awk, but I'll give a try with sed to compare the performance (I'm sorry but fish doesn't support native string manipulation till now).
function __promptline_cwd
set -lx dir_limit "3"
set -lx truncation "⋯ "
set -lx first_char ""
set -lx part_count 0
set -lx formatted_cwd ""
set -lx dir_sep " "
set -lx tilde "~"
set -lx cwd (echo | awk "{pwd=\"$PWD\"; sub(\"$HOME\", \"~\", pwd); print pwd}")
# get first char of the path, i.e. tilde or slash
set -lx first_char (echo "$cwd" | awk '{print substr($0,0,1)}')
# remove leading tilde
set -lx cwd (echo | awk "{pwd=\"$cwd\"; sub(\"~\", \"\", pwd); print pwd}")
while begin test (echo $cwd | awk '{print gsub(/\//,"")}') -gt 0; and test "$cwd" != "/"; end
# pop off last part of cwd
set -lx part (echo $cwd | awk -F'/' '{print $NF}')
set cwd (echo $cwd | awk -F'/' '{OFS="/";NF--;print $0;}')
set formatted_cwd "$dir_sep$part$formatted_cwd"
set part_count (echo (math part_count+1))
if test "$part_count" = "$dir_limit"
set first_char "$truncation"
break
end
end
printf "%s" "$first_char$formatted_cwd"
end
from promptline.vim.
Thanks!
Please don't do any performance optimizations for now. I'll try to come up with a decent way to keep the fish code in the repository. Will let you know when I have something working
from promptline.vim.
All right!
I think the easiest way for the users would be if we only check the file extension (e.g. :PromptlineSnapshot ~/.shell_prompt.fish airline
). For the *.fish
case you can set a variable fish
and in the slices I'll check it to switch between shell and fish, because the fish code is so different from the shell code, that we have to seperate it from each other. (That's my opinion. Better proposals are always welcome!)
from promptline.vim.
After giving some thought to this, I think this might be a decent approach: instead of duplicating all the code in the repo and spawning tons of sed/awk/grep processes during runtime, just spawn one bash process to render the prompt.
This might seem a bit ugly at first, but could do the job pretty well I think: fish doesn't have much advanced scripting functionalities (which is it's design decision) so it would need some external tool to render the prompt. bash could be this "external tool", with something like:
function fish_prompt
bash ~/.promptline.sh
end
I did a quick prototype and it seems quite functional... although there is some issue with colors/quoting.
Please let me know what you think of this approach. Do you see any pitfalls?
from promptline.vim.
Here's the prototype, colors & escaping is fixed here:
from promptline.vim.
Your approach looks nice! Nevertheless I ported the shell code to fish and made (IMHO) some improvements. But you're right when you saying:
[...] duplicating all the code in the repo and spawning tons of sed/awk/grep processes
during runtime [...]
So firstly I don't wan't to integrate all the duplicated code into the repo, because I'm not sure if it would make sense to maintain the code twice (if you want, you can do it 😉) and secondly the bad string manipulation made me unhappy so I took care of it and now there is something happen (last comment from @kballard) at the fish-shell project. For now it's a little bit slow, but with the coming improvements I think it'll be fast like your version.
Here is the .promptline.fish and that's a little demo:
PS: I tested the script on Ubuntu 14.04 and OS X (10.9).
from promptline.vim.
I just commented on the gist with a rewritten version of __promptline_cmd
that gets rid of most of the process spawning. I didn't directly compare the speeds (since I don't actually have Promptline installed; it's sitting on my to-do list), but it should be much faster.
from promptline.vim.
@kballard Thank you ever so much! I updated and commented the gist.
@AnderRasoVazquez If you are still interested in a fish version take a look at this gist.
from promptline.vim.
Great, thanks for sharing the gist! However, I'll stick with the approach I described above (fish will execute a bash script to get its prompt) as this would keep the codebase simpler. Once fish has string manipulation capabilities, I might revisit this topic.
Will let you know when fish support is added to promptline.
BTW sorry for the late response, I was away for a couple of weeks :)
from promptline.vim.
Support for fish is now added! @mamiu thank you very much!
from promptline.vim.
This is great guys, I've followed the developing since beginning. Times like this makes open source great.
Thank you =)
from promptline.vim.
Related Issues (20)
- Preset cannot be found
- Truncation character (U+22EF) not being displayed HOT 1
- Running tmux messes up colors. HOT 1
- Possible to note directory changes and detailed git status?
- Prompt Notifications/Statuses HOT 1
- Style is only loaded after a vim session.
- What color scheme is this?
- Unmatching arrow? HOT 2
- Unknown function from vimrc while launching vim HOT 1
- no true color support HOT 6
- If there is '/' contain in git branch name, vcs_branch show incorrect branch name. HOT 2
- termguicolors not working
- battery checking errors on mac desktops (fix provided!) HOT 2
- Xonsh Shell support?
- Support for Kubernetes
- cwd slice doesn't understand zsh static named directories HOT 6
- promptline looks poor when in Fbterm running in tty1
- Is promptline smart enough to know about its size?
- E117: Unknown function: promptline#slices#host HOT 1
- promptline with tmuxline overwrites the prompt when the command line is too long
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from promptline.vim.