Giter VIP home page Giter VIP logo

Comments (10)

zerocool4u2 avatar zerocool4u2 commented on July 20, 2024

@poma hi, i'm having some little troubles with this, first, i couldn't ever change my shell to zsh with chsh command, so i start my outbash.exe with ~ -c "zsh --login", so i'm entering to the bash case, because my $SHELL variable is "/bin/bash", then i changed it to command_not_found_handler() to get it properly working, but the thing is that the if statement of try_cbwin gets executed and throws an error because is trying to find a "which" file, if i change it to $COMMAND "$1" then i get the command executed twice, my question is, is this only happening to me because i didn't change the shell properly? and if you could walk me through that if statement on what is doing, i don't really know that much about shell scripting, i know this > /dev/null 2>&1 is for redirect the error output(right?xd), but the first part and what is the which for, no clue, i would really like to have this working and also add support, eventually, for the case of been on the home_directory and automatically append the : for using windows_home_path in those cases, thanks in advance, regards!

from cbwin.

poma avatar poma commented on July 20, 2024

Try sudo chsh -s /bin/zsh yourUser

The idea of this script is to run which command in windows shell to determine if a file (first argument) exists. We are not interested in its output (hence > /dev/null 2>&1), we just need the return code. If it succeeds then run the whole command in windows. Obviously it will work only for executables and not built-in cmd commands.

I've just realized that my script uses which command provided by Cygwin and that's why it doesn't work on your machine. The windows equivalent for which is where. I've fixed my script to reflect that.

from cbwin.

poma avatar poma commented on July 20, 2024

Also updated script to allow commands from home dir (false by default) but be careful with it

from cbwin.

zerocool4u2 avatar zerocool4u2 commented on July 20, 2024

thanks man! works perfect!! i couldn't be happier right now, i really appreciated, chsh in the other hand, still not working, i just change "command_not_found_handle" to "handler" for now, if it becomes a problem in the future, so it be lol, thanks again man and take care, regards!
PD: time to delete all those aliases =)

from cbwin.

xilun avatar xilun commented on July 20, 2024

Cool script! Any idea if Ctrl-Z can be made to work properly with it? Oddly suspension is propagated to the win32 side but I don't get back the shell prompt (tried with bash)

from cbwin.

xilun avatar xilun commented on July 20, 2024

Update about Ctrl-Z: hm and it's not just because of the use of a function and not even because of the use of command_not_found_handle. Weird. I will take another look later.

from cbwin.

poma avatar poma commented on July 20, 2024

Found a bug: this script will override default command-not-found script that suggests to install packages when command is not found (enabled in bash by default and in zsh via command-not-found plugin). Updated my script to copy and invoke old function if it is defined. Also I've missed quotes around @$ in first version. Result is a bit verbose and probably still has some bugs as I have no experience with bash

from cbwin.

poma avatar poma commented on July 20, 2024

@xilun Ctrl-Z works for me. I can successfully freeze notepad, get shell prompt, and then unfreeze it.

from cbwin.

xilun avatar xilun commented on July 20, 2024

More testing: with this command not found handler, Ctrl-Z works under zsh, but not bash. This might be a bash bug or a WSL bug, I'm looking into it.

from cbwin.

xilun avatar xilun commented on July 20, 2024

This seems to be mainly a bash bug, however the behavior of bash is actually worse on a real Linux system in this case (Ctrl-C after a Ctrl-Z does not work), so there might also be a WSL bug (which in this case slightly improves the usability) to find in there :p

from cbwin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.