|
1 | | -# ecd & eopen |
| 1 | +# eopen (+ecd) |
2 | 2 |
|
3 | | -Change directory to each other between Terminal and Explorer. |
| 3 | +Open Explorer from WSL Terminal (plus PowerShell, Command Prompt). |
| 4 | +Change directory of Terminal to Explorer location. |
| 5 | + |
| 6 | +## Supported Windows and Terminals |
| 7 | + |
| 8 | +* `Windows 10 64bit 1903` or later recommended, |
| 9 | +* Probably works on `Windows 7` (include 32bit) or later. |
| 10 | +* `WSL` / `WSL2` recommended for the terminal. |
| 11 | +* Semi-support for `Powershell` and `Command Prompt`. |
4 | 12 |
|
5 | 13 | ## Usage |
6 | 14 |
|
7 | | -**Note** Require to enable `Launch folder windows in a separete process` in *Explorer* -> *File* -> *Change folder and search options* -> *View* -> *Advanced settings*. |
| 15 | +### eopen |
8 | 16 |
|
9 | | -`ecd` - Change the terminal directory to the current explorer location. |
| 17 | +Open the file or change the directory from the Terminal via a shell (Explorer). |
| 18 | + |
| 19 | +#### Examples |
10 | 20 |
|
11 | 21 | ``` |
12 | | -Usage: ecd |
13 | | -``` |
| 22 | +# Open directory with (latest used) Explorer |
| 23 | +eopen ~/.config/ |
14 | 24 |
|
15 | | -`ewd` - Display linux path of current explorer location. |
| 25 | +# Open directory with new instance of Explorer |
| 26 | +eopen -n ~/.config/ |
16 | 27 |
|
17 | | -``` |
18 | | -Usage: ewd |
19 | | -``` |
| 28 | +# Opens with Windows default application |
| 29 | +eopen image.png |
20 | 30 |
|
21 | | -`eopen` - Open the file or change the directory from the terminal via a shell (explorer). |
| 31 | +# Opens with Windows text editor |
| 32 | +eopen -e ~/.bashrc |
22 | 33 |
|
23 | | -``` |
24 | | -Usage: eopen [options] [file | directory | uri] |
| 34 | +# Use sudo to edit the unowned file |
| 35 | +eopen -e --sudo /etc/hosts |
25 | 36 |
|
26 | | -options: |
27 | | - -e, --editor Open the file in text editor ($EOPEN_EDITOR) |
28 | | - -n, --new Open the specified directory in new instance of explorer |
29 | | - --sudo Use sudo to write the unowned file |
30 | | - -v, --version Display the version |
31 | | - -h, --help You're looking at it |
| 37 | +# Opens with Windows default browser |
| 38 | +eopen http://google.com |
32 | 39 |
|
33 | | -note: |
34 | | - The file or the directory allows linux and windows path. |
35 | | - (e.g. /etc/hosts, C:/Windows/System32/drivers/etc/hosts) |
| 40 | +# Open other protocols |
| 41 | + |
| 42 | +eopen shell:downloads |
| 43 | +eopen calculator: |
| 44 | +eopen msnweather: |
| 45 | +eopen ms-settings: |
| 46 | +eopen xboxliveapp-1297287741: # Solitaire |
36 | 47 |
|
37 | | - The uri must start with protocol schema. (e.g http:, https:) |
| 48 | +# Open files and directories under Windows |
| 49 | +eopen C:/Windows |
| 50 | +
|
| 51 | +# Open files and directories under Network shared folder |
| 52 | +eopen //server/shared |
38 | 53 | ``` |
39 | 54 |
|
40 | | -### WSL terminal |
| 55 | +**Note** If you use `eopen -e`, you need to set the execution path to |
| 56 | +`EOPEN_EDITOR` environment variable for Windows (not WSL). |
| 57 | + |
| 58 | +**Note** `eopen` for PowerShell and Command Prompt are currently not |
| 59 | +implemented. It just alias of `explorer.exe`. |
| 60 | + |
| 61 | +### ewd |
| 62 | + |
| 63 | +Print linux path of the (latest used) explorer location. |
| 64 | + |
| 65 | +### ecd |
41 | 66 |
|
42 | | -Define alias refer to the following and type `ecd`. |
| 67 | +Change the terminal directory to the (latest used) explorer location. |
43 | 68 |
|
44 | | -**Note** If you use `eopen -e`, you need to set the execution path to `EOPEN_EDITOR` environment variable. |
| 69 | +### epushd |
45 | 70 |
|
46 | | -#### For sh |
| 71 | +Change the terminal directory to the (latest used) explorer location, |
| 72 | +And add directories to stack. (Use `pushd` instead of `cd`.) |
47 | 73 |
|
48 | | -`bash`, `zsh`, `ksh` and compatibile shells. |
| 74 | +**Note** Not available on `ksh` and `mksh`, since `push` is not implemented. |
| 75 | + |
| 76 | +## Download |
| 77 | + |
| 78 | +**Download from [releases page](https://github.com/ko1nksm/eopen/releases)** |
| 79 | + |
| 80 | +**Note** Highly recommend using x64 binary on Windows 10 64bit edition. |
| 81 | +x86 binary is also work, but access to the WSL path (`\\wsl$\...`) from |
| 82 | +32bit process is unstable. (Related? [issue 4260][4260] of microsoft/WSL) |
| 83 | + |
| 84 | +[4260]: https://github.com/microsoft/WSL/issues/4260 |
| 85 | + |
| 86 | +**Note** It is also distributed for Windows 10 ARM / ARM64. |
| 87 | +But I do not have those platforms. So it has not been tested at all. |
| 88 | + |
| 89 | +## Installation |
| 90 | + |
| 91 | +Extract the zip file to any directory and set to your shell's profile. |
| 92 | + |
| 93 | +**Note** Require to enable `Launch folder windows in a separete process` in |
| 94 | +*Explorer* -> *File* -> *Change folder and search options* -> *View* |
| 95 | +-> *Advanced settings*. |
| 96 | + |
| 97 | +### WSL terminal |
| 98 | + |
| 99 | +Change the following line to the appropriate path and add it to your |
| 100 | +shell's profile under your home directory. |
| 101 | + |
| 102 | +#### For POSIX compliant shells |
49 | 103 |
|
50 | 104 | ```sh |
51 | | -alias ecd='eval "$(/path/to/wsl/ecd.sh)"' |
52 | | -alias ewd='/path/to/wsl/ewd.sh' |
53 | | -alias eopen='/path/to/wsl/eopen.sh' |
| 105 | +eval "$(sh "/path/to/eopen/init.sh")" |
54 | 106 | ``` |
55 | 107 |
|
| 108 | +[Profile] **bash:** `.bashrc`, **zsh:** `.zshrc`, **ksh:** `.kshrc`, |
| 109 | +**mksh:**, `.mkshrc`, **yash:** `.yashrc` |
| 110 | + |
56 | 111 | #### For tcsh |
57 | 112 |
|
58 | 113 | ```sh |
59 | | -alias ecd 'eval `/path/to/wsl/ecd.sh`' |
60 | | -alias ewd '/path/to/wsl/ewd.sh' |
61 | | -alias eopen '/path/to/wsl/eopen.sh' |
| 114 | +eval `sh "/path/to/eopen/init.sh" tcsh` |
62 | 115 | ``` |
63 | 116 |
|
| 117 | +[Profile] **tcsh:** `.tcshrc` |
| 118 | + |
64 | 119 | #### For fish |
65 | 120 |
|
66 | 121 | ```sh |
67 | | -alias ecd='eval (/path/to/wsl/ecd.sh)' |
68 | | -alias ewd='/path/to/wsl/ewd.sh' |
69 | | -alias eopen='/path/to/wsl/eopen.sh' |
| 122 | +eval (sh "/path/to/eopen/init.sh" fish) |
70 | 123 | ``` |
71 | 124 |
|
72 | | -### Command prompt |
| 125 | +[Profile] **fish:** `.config/fish/config.fish` |
73 | 126 |
|
74 | | -Type `ecd` (`ecd.bat`) or `epushd` (`epushd.bat`). |
| 127 | +### PowerShell |
75 | 128 |
|
76 | | -**Note** `epushd.bat` uses `pushd` command instead of `cd`. So you can restore directory by `popd` and use UNC path. |
| 129 | +Change the following line to the appropriate path and add it to your |
| 130 | +PowerShell's profile. |
77 | 131 |
|
78 | | -### PowerShell |
| 132 | +```powershell |
| 133 | +. "/path/to/eopen/init.ps1" |
| 134 | +``` |
79 | 135 |
|
80 | | -**Note** Require to change execution policy. (Google `Set-ExecutionPolicy`). |
| 136 | +To edit profile, type `notepad $PROFILE` in PowerShell. |
81 | 137 |
|
82 | | -Add the following code to your profile (Run `notepad $profile` to edit) and type `ecd`. |
83 | 138 |
|
84 | | -```powershell |
85 | | -Set-Alias ecd "/path/to/pwsh/ewd.ps1" |
| 139 | +**Note** Require to change PowerShell execution policy. |
| 140 | +(Google `Set-ExecutionPolicy`). |
| 141 | + |
| 142 | +### Command prompt |
| 143 | + |
| 144 | +Change the following line to the appropriate path and add it to `profile.bat` |
| 145 | +(or favorite name) |
| 146 | + |
| 147 | +```batch |
| 148 | +@call \path\to\eopen\init.bat |
86 | 149 | ``` |
87 | 150 |
|
88 | | -## Thanks |
| 151 | +Load it to Command Prompt. (For example, use `cmd /k profile.bat`) |
| 152 | + |
| 153 | +## For developers |
| 154 | + |
| 155 | +### Architecture |
| 156 | + |
| 157 | +The `ebridge.exe` is helper module that operate shell (Explorer) via |
| 158 | +COM Automation. All scripts are thin frontend of the `ebridge.exe`. |
| 159 | + |
| 160 | +### How to build ebridge.exe |
| 161 | + |
| 162 | +Require to install [Visual Studio 2019][vs2019] to build. |
| 163 | +(Free Community Edition is enough.) |
| 164 | + |
| 165 | +[vs2019]: https://visualstudio.microsoft.com/downloads/ |
| 166 | + |
| 167 | +To build, the following steps after installation of Visual Studio 2019 |
| 168 | + |
| 169 | +1. Run `Developer Command Prompt for VS 2019` from the *start menu* |
| 170 | +2. Goto project root directory |
| 171 | +3. Run `build.bat <TARGET...>` (TARGET: `x86`, `x64`, `arm`, `arm64`) |
| 172 | +4. Generate archive files to the `dist` directory. |
| 173 | + |
| 174 | +Or double click `ebridge.sln` in the [src](src) directory to launch Visual Studio IDE. |
| 175 | + |
| 176 | +### Test |
| 177 | + |
| 178 | +None, should be do. |
| 179 | + |
| 180 | +## History |
| 181 | + |
| 182 | +The formerly name of this project was `ecd` that was started to port |
| 183 | +the `fcd` for macOS to Windows. |
| 184 | + |
| 185 | + * [fcd](http://www.script-factory.net/software/terminal/fcd/index.html) - Script factory |
| 186 | + * [fcd](https://qiita.com/Yuhsak/items/a1f154f14e5ff871b6d2) - another one-liner version |
| 187 | + |
| 188 | +The core module was written with PowerShell script. Early version of |
| 189 | +`ecd` and `eopen` were relies on the script. It was a bit slow (about 400ms-). |
| 190 | +So I rewrote the core module as native by VC++. |
| 191 | +And `eopen`, which has many features, has been changed to the main. |
89 | 192 |
|
90 | | -[fcd](https://qiita.com/Yuhsak/items/a1f154f14e5ff871b6d2) (macOS version of this. The idea was taken from here). |
| 193 | +[CHANGELOG](CHANGELOG.md) |
91 | 194 |
|
92 | 195 | ## License |
93 | 196 |
|
|
0 commit comments