Comments (9)
Hello again,
I just create a "Pull request" with working implementation: #34
I hope you find it useful.
I'm new to bash scripting and this was quite of a challenge for me, but I'm glad that I manage to get it working.
I'll be very happy if someone can provide me his personal feedback on the changes and/or propose improvements.
from with.
I've been working on this for the last week or something and I think I have a working solution.
It is not perfect but I think that it is pretty good for start.
The last thing that is left is to move the cursor to the appropriate place after a word completion is made.
Does anybody have an idea how this can be done?
from with.
Maybe the solution is not to have your own REPL, but to hook up to bash command execution? I've never done that, I wonder if that's possible.
Is this interesting?
from with.
@wilhelmtell so use preexec to get a list of all the completions? Definitely an interesting option. It saves us having to use an external tool like rlwrap or writing a custom c program. It does seem a little unsafe though. I'm thinking of just writing a c program to do the work.
from with.
rlwrap won't help. What I meant is, you want to stay in the user's environment, in the user's bash prompt. This way, all the user's settings are there -- including their completions, their bash prompt, their word expansions, everything. All you want to do is prefix their commands, that's it. Not take the command from them, not provide completion for them, not provide a prompt for them. If you stay out of the REPL, you don't need to worry about any of these.
So, googling for that, I found that hint about hooking up to the bash command execution. So I wondered if it's possible to set up a hook that is run before any command bash executes, that gives you the command prior to executing it, and allows you to alter it.
Then, you'd need two commands, rather than a with
and an EOF: one command to hook onto the command execution, and one to unhook.
from with.
Alright. That's what I was looking into. It seems running exec with xdotool
and the prompt + \t\t can get a list of completions. And once we have those it's a matter of sending them back to the main shell via a file and using the list of completions.
Not sure how you could hook bash in the same process.
from with.
If possible the solution must not use external tools.
from with.
@dragonator I'm currently looking through the code. Your pull request seems great though. Thank you. I think I'll bump it up to version 0.0.2 after the code review.
from with.
It seems that now we don't have file name completion.
from with.
Related Issues (20)
- Error when using sh. Script should use Bash by default. HOT 2
- doesn't quit with ^D, ^C cancels process instead of current line HOT 2
- colours get lost HOT 2
- Syntax error: "(" unexpected (expecting "fi") HOT 6
- Shellcheck HOT 1
- Syntax error on Linux Ubuntu with #!/usr/bin/env sh HOT 2
- Include tests
- Installation with zsh HOT 1
- Add support for shell syntax in `:`-prefixed lines HOT 2
- Correct readme HOT 1
- Port to windows batch script HOT 1
- Port script to POSIX sh
- Retain prompt or allow user prompt
- sed -r not supported on on osx HOT 7
- Program not installed HOT 6
- sed: 1: "s/%prefix%/curl -vvv ht ...": bad flag in substitute command: '/' HOT 2
- Configure for windows bash
- Doesn't work with aliases
- with --help: print_help command not found HOT 1
- Include full command in shell history HOT 2
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 with.