reddit / emacs

Amazing in native Windows 11's Emacs28.1 to get Linux environment as shell-command and interactive shell

AbstProcDo · 2022-04-23 05:03
It's amazing to run everything with Linux within Emacs 28.1 of native wins version, but just need two lines of codes: (setq shell-file-name "C:/Windows/system32/bash.exe") (setenv "ESHELL" "bash") 1. Then you could get a bash shell of wsl-linux after M-x shell: https://preview.redd.it/xjjcj2wmh7v81.png?width=913&format=png&auto=webp&s=9d4d5e7f37e53e609331a281cc13fae156645836 2. Invoke shell-command(M-!) in bash environment rather than cmd.exe: https://preview.redd.it/9mv9hnrri7v81.png?width=814&format=png&auto=webp&s=f125a946a340bcd80bff12d77892f827ef9f1f43 Yeah, cmd.exe environment gone. you can comfortable run "git add .; git commit -m 'comment'; git push" now in bash environment. ​ 3. Also surprising to find the any 'commands' bind to ones of wsl-linux, grep-find, counsel-rg for example: M-x grep-find (find . -type f -exec grep -nH -e 'shell-file-name' \{\} \;) https://preview.redd.it/6ctmjrcwj7v81.png?width=960&format=png&auto=webp&s=f0a6c0b4fe8b022a626fb9c8b16ea5d870b39b39 It's grep and find in wsl environment not ones of scoop in cmd.exe or powershell.exe, just surprising. ​ 4.Try counsel-rg to search Chinese characters https://preview.redd.it/z7xphhckk7v81.png?width=790&format=png&auto=webp&s=78386487066b3a544ff2123d324039badebcfe1e 5.Additional, Linux manuals works from M-x man: https://preview.redd.it/n1emg1ruk7v81.png?width=799&format=png&auto=webp&s=9f9104f4e66fe32d350b0b28047e7bac787dbc0d 6. Open other windows native apps from Emacs with M-& (async-shell-command) . https://preview.redd.it/yleomzo1m7v81.png?width=954&format=png&auto=webp&s=d3fef69f54db8e4942f2643de56be9c3ad0954cc It works on 28.1 but fails in 27.2. Finally, babel-src block in org https://preview.redd.it/zpywf7aem7v81.png?width=777&format=png&auto=webp&s=7f61cb859698acb769bf3400920083b1fa57b437 Achieve all above functions, only two lines of codes in emacs 28.1 (setq shell-file-name "C:/Windows/system32/bash.exe") (setenv "ESHELL" "bash") Amazing. No needs of GWSL any more or VcxSrv or X410 desktop.
Mamonimoni · 2022-04-23 06:10
Watch out linux! there is a new kid coming after you!
AbstProcDo · 2022-04-23 06:12
exciting so much.
lispstudent · 2022-04-23 06:30
Than you. This is going to be one of the nicest productivity increases in my workflow.
AbstProcDo · 2022-04-23 06:31
Sure, productivity is taking off.
grimscythe_ · 2022-04-23 07:37
I'd rather just use Linux anyway...
TarMil · 2022-04-23 07:54
What's WSL git on the windows file system like, performance wise?
AbstProcDo · 2022-04-23 10:10
The first step is letting it working.
onearmedphil · 2022-04-23 11:14
This is awesome thanks! What is the audio player you’re using?
AbstProcDo · 2022-04-23 11:42
Glad to help, I use win11's default "Media Player", it was called "Groove Music" on Win10.
ifqqfi · 2022-04-23 14:33
Is the filesystem performance issue fixed? Otherwise, it can't be used in lots of real projects.
SequentialDesign · 2022-04-23 14:33
woohooo!!!! THANK YOU SO MUCH!! this is already EPIC 😁
noman_032018 · 2022-04-23 14:43
Windows now includes bash?
AbstProcDo · 2022-04-23 14:54
C:/Windows/system32/bash.exe invokes WSL.
AbstProcDo · 2022-04-23 14:55
Agreed :>
noman_032018 · 2022-04-23 14:58
Ah, interesting to know. Is that by default?
bugamn · 2022-04-23 14:59
>Yeah, cmd.exe environment gone. you can comfortable run "git add .; git commit -m 'comment'; git push" now in bash environment. But is it going to work with magit without extra configuration?
onearmedphil · 2022-04-23 15:17
oh ok lol. i thought it was a module in emacs and was intrigued.
AbstProcDo · 2022-04-23 15:27
Magit is slow with both native windows emacs and wsl' emacs.
AbstProcDo · 2022-04-23 15:28
M-& explore.exe open file with default windows apps.
bugamn · 2022-04-23 15:31
That's a shame, magit is a gamechanger for me
DrReadIt · 2022-04-23 16:03
Not, until the fix the Forking Fork implementation on Windows.
cazdal · 2022-04-23 16:07
You need to install WSL for it.
noman_032018 · 2022-04-23 16:14
Ah good to know. That helps me know how much I can rely on that with companies that require Windows use.
cazdal · 2022-04-23 16:22
Np. WSL 2 automatically releases unused RAM back to Windows, and on 11 lets you run graphical applications instead of just text shells (so you can then i.e. run Emacs from within WSL).
noman_032018 · 2022-04-23 16:23
> WSL 2 automatically releases unused RAM back to Windows It has [memory ballooning](https://en.wikipedia.org/wiki/Memory_ballooning), that's nice.
sunnyata · 2022-04-23 17:14
Lol
johnisfine · 2022-04-23 17:35
Not sure if it's caused by the same thing you mentioned but 2 days ago I've tried to do some Unity development with Emacs on Windows and it was lagging too much to be usable. It still can't be used in real projects yeah, so Linux is the only option.
DrinkingCoffe · 2022-04-23 17:48
just tried it, any luck with the find-file ( C-x C-f ) command ?, when Im navigating through the directories in the bash shell and then try to open a file in the current directory, emacs does not position the current directory in the mini-buffer to the current directory in the bash shell, essential QOL.
pipilu84 · 2022-04-23 18:10
most importantly, can you make pdftools work?
AbstProcDo · 2022-04-23 23:36
I tried and no problems with C-x C-f (ivy-package).
AbstProcDo · 2022-04-23 23:38
I assume it might better to open pdf with default "adobe reader pro" by M-& explore.exe some-book.pdf.
[deleted] · 2022-04-24 02:45
[deleted]
harunokashiwa · 2022-04-24 06:48
tested in [emcas 29](https://github.com/kiennq/emacs-build), `M-x shell` can run neofetch too.
WSL_subreddit_mod · 2022-04-24 07:06
It's as fast as a native Linux file system
WSL_subreddit_mod · 2022-04-24 07:07
WSL is Linux
WSL_subreddit_mod · 2022-04-24 07:10
If using WSL(1) it performs as well as a Windows native git.
WSL_subreddit_mod · 2022-04-24 07:10
/r/bashonubuntuonwindows
WSL_subreddit_mod · 2022-04-24 07:12
I just used pdf tools in WSL to merge 2 pdfs this week.
ifqqfi · 2022-04-24 11:47
How about accessing windows native files? I tried it before, it's unacceptably slow.
WSL_subreddit_mod · 2022-04-24 12:32
Accessing Windows files with WSL1 is native, as fast as NTFS on Windows. NTFS has different performance for small file read/writes than ext4. If you are doing a task that has massive amounts of IO to the Windows file system then you should use WSL1. Often someone wants something compiled to exist in Windows, and uses WSL2 for a massive amount of small file io. It's important to remember that Windows can access WSL2 filesystems. So the correct sequence in making that available to Windows isn't to work there, but use the result stored or transferred from WSL2 directly from Windows. What exactly was your use case?
WSL_subreddit_mod · 2022-04-24 12:33
Why don't you post this over at /r/bashonubuntuonwindows
pipilu84 · 2022-04-24 14:06
are you using wsl emacs with pdf-tools or the native windows emacs?
bugamn · 2022-04-24 17:49
I'm testing this now on a windows machine and it doesn't seem to work for me. When I tried to open the man page for 'find' with 'man' I got "/bin/bash: line 1: NUL: Permission denied" Then I tried to grep my init.el for System, and I got an error 255. It seems emacs is sending a NUL to the program and that is causing an error. Here's the output, it had a lot more \\0 lines, but I abbreviated it: -*- mode: grep; default-directory: "~/.emacs.d/" -*- Grep started at Sun Apr 24 10:45:10 grep -n System init.el NUL \0 [...] \0 Grep exited abnormally with code 255 at Sun Apr 24 10:45:10
WSL_subreddit_mod · 2022-04-24 18:53
Everything is WSL. I don't often duplicate toolkits.
ifqqfi · 2022-04-25 12:39
I have a project use win toolchain to compile ,but I want to use emacs and git to manage the source code in WSL.
WSL_subreddit_mod · 2022-04-25 13:22
Ok. Once synced git changes are generally small diffs on files. The overhead of using WSL would be negligible. Also, you would use WSL1, where there would be zero overhead. The only thing you would do, which isn't unique to WSL, is add exceptions to Defender to not scan your project folders so that when heavy IO happens there is no antivirus penalty. Or add a specific exception for Git. But, just to summarize, WSL1 would have no penalty regarding file access, and you can use Emacs and git.
Shivalicious · 2022-04-26 13:42
One of the most depressing experiences I’ve had lately was finding out that even Magit on Linux over TRAMP is so much faster than Magit on Windows.
ambihelical · 2022-04-28 15:50
I haven't found magit to be "slow" on windows native emacs, but I do remove some time consuming sections: (remove-hook 'magit-status-sections-hook 'magit-insert-status-headers) (remove-hook 'magit-status-sections-hook 'magit-insert-stashes) (remove-hook 'magit-status-sections-hook 'magit-insert-tags-header) (remove-hook 'magit-status-sections-hook 'magit-insert-unpulled-from-upstream)
Shivalicious · 2022-04-28 20:51
Unfortunately, I think the only one of those sections I *might* not find useful is the unpulled commits one, and even that helps to get my bearings.