Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/linusic/ranger-wsl
πThe content of this repository is about the configuration,scripts and custom commands of Ranger in the WSL environment
https://github.com/linusic/ranger-wsl
python ranger wsl
Last synced: 2 months ago
JSON representation
πThe content of this repository is about the configuration,scripts and custom commands of Ranger in the WSL environment
- Host: GitHub
- URL: https://github.com/linusic/ranger-wsl
- Owner: linusic
- Created: 2022-05-23T08:50:32.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-15T08:10:21.000Z (over 2 years ago)
- Last Synced: 2024-07-30T21:04:27.905Z (5 months ago)
- Topics: python, ranger, wsl
- Language: Python
- Homepage:
- Size: 2.27 MB
- Stars: 3
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ranger-wsl
The content of this repository is about the configuration,scripts and custom commands of `Ranger` in the `WSL` environment- π[Ranger](https://github.com/ranger/ranger)
- π[WSL](https://github.com/microsoft/WSL)You can run WindowsOS Applications in your WSL-Ranger
- π`editor`: use your windows [sublime text](https://www.sublimetext.com/) / `notepad.exe` as your default editor for `Ranger`
- π`player`: use your windows browser to open Audio/Video/PDF (or use others app VLC ...)
- π`compress/extract`: I just provide `Rar.exe/unRar.exe` code for `WinRar.exe`
- ...
- If WindowsOS App provides a command line to start, then you can integrate them into WSL-Ranger## Requirements
You need to have the following:
- π₯ **Python3.6 +**## Instructions
my `WSL` path format is default, so the `prefix` is :π
```shell
/mnt/# eg:
# /mnt/c
# /mnt/d
# /mnt/e
# ...```
all my scripts follow above path format `prefix`π
> π₯If you had changed your default location of `WSL` , eg: not `/mnt/`
> π₯you need to change these scripts by yourself, replace to your own path format
> π`Python3.6+`## Core Script
- `ri_script/wsl_2_path.py`
- `ri_script/wsl_2_abspath.py` (Just for bulkrename and Rar)
- `ri_script/wsl_2_url.py` (For browser)> the contents of scripts are very simple.
> but the main idea is: `Which applications` need to be converted to `which path format`.eg: you can run `chrome.exe` to open `Video/Audio/PDF` and more files
- but you cant't open them with absolute path
- you must switch: `/mnt/{}/xxx` to `file:///{}:/xxx`
- for details, you can try: `ri_script/wsl_2_url.py`## commands.py
- bulkrename: change editor in `rc.conf` => `mime ^text, label editor =`
- changed: default editor is `subl.exe` you can set your editor π- fzf_select
- refer from [ranger-wiki](https://github.com/ranger/ranger/wiki/Custom-Commands#fzf-integration):
- changed: some code and add my fzf remap/config- fzf_mark
- I add the fzf_mark, you can also see [fzf_mark](https://github.com/ranger/ranger/wiki/Custom-Commands#fzf-filter-and-mark)- extract_here & compress
- refer from [archlinux-wiki](https://wiki.archlinux.org/title/Ranger#Compression)
- changed: replace `atool` in ArchLinux to `WinRAR.exe` in Windows for WSL## rifle.conf
you can see the type of files name `suffix` and associated WindowsOS Applications## rc.conf
you can see above π `commands.py` remap in `rc.conf`
> end of `rc.conf` => `source ~/rc_remap.conf` is for AutoWalk π## [AutoWalk](https://github.com/linusic/autowalk)
you can AutoWalk to bulk add remap for Ranger for paths in your filesystem## Others
### JupyterLab For Ranger
In ranger, you can open `.ipynb` on JupyterLab directly;
But it depends on [PM2](https://github.com/Unitech/pm2);
add below in your `rifle.conf`:
```shell
ext ipynb = python3 ~/ri_script/jlab_ranger.py $1
```
> Note: you need to adjust the paths of the script: `ri_script/jlab_ranger.py` to your `home_dir`### Launch WSL Application on Windows directly
Maybe some configure didn't work with `wsl.exe --exec`, you can try πput source application configure into `/etc/profile`
> Q: Why `/etc/profile` rather than `~/.zshrc` ?
> A: Decoupling makes `bash` faster than `zsh` for launching (Ranger just needs `fzf configure`)```shell
echo '[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh' >> /etc/profile
```
then put below code into your windows app manager (Lnk ...)
```shell
wsl.exe --exec /bin/zsh -c "source /etc/profile && ranger /mnt/d/test"
```