Skip to content

Commit 6694276

Browse files
committed
Merge 0.8.0 branch
1 parent 3dc9a56 commit 6694276

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1778
-223
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/bin/*.exe
2+
/dist
3+
/tmp

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
## Unreleased
4+
5+
## 0.8.0 - 2019-11-03
6+
7+
- Windows native implementation
8+
- Improve perfomance
9+
10+
## Before 0.8.0
11+
12+
- Slow PowerShell implementation version

README.md

Lines changed: 150 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,196 @@
1-
# ecd & eopen
1+
# eopen (+ecd)
22

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`.
412

513
## Usage
614

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
816

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
1020

1121
```
12-
Usage: ecd
13-
```
22+
# Open directory with (latest used) Explorer
23+
eopen ~/.config/
1424
15-
`ewd` - Display linux path of current explorer location.
25+
# Open directory with new instance of Explorer
26+
eopen -n ~/.config/
1627
17-
```
18-
Usage: ewd
19-
```
28+
# Opens with Windows default application
29+
eopen image.png
2030
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
2233
23-
```
24-
Usage: eopen [options] [file | directory | uri]
34+
# Use sudo to edit the unowned file
35+
eopen -e --sudo /etc/hosts
2536
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
3239
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+
eopen mailto:[email protected]
42+
eopen shell:downloads
43+
eopen calculator:
44+
eopen msnweather:
45+
eopen ms-settings:
46+
eopen xboxliveapp-1297287741: # Solitaire
3647
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
3853
```
3954

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
4166

42-
Define alias refer to the following and type `ecd`.
67+
Change the terminal directory to the (latest used) explorer location.
4368

44-
**Note** If you use `eopen -e`, you need to set the execution path to `EOPEN_EDITOR` environment variable.
69+
### epushd
4570

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`.)
4773

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
49103

50104
```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")"
54106
```
55107

108+
[Profile] **bash:** `.bashrc`, **zsh:** `.zshrc`, **ksh:** `.kshrc`,
109+
**mksh:**, `.mkshrc`, **yash:** `.yashrc`
110+
56111
#### For tcsh
57112

58113
```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`
62115
```
63116

117+
[Profile] **tcsh:** `.tcshrc`
118+
64119
#### For fish
65120

66121
```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)
70123
```
71124

72-
### Command prompt
125+
[Profile] **fish:** `.config/fish/config.fish`
73126

74-
Type `ecd` (`ecd.bat`) or `epushd` (`epushd.bat`).
127+
### PowerShell
75128

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.
77131

78-
### PowerShell
132+
```powershell
133+
. "/path/to/eopen/init.ps1"
134+
```
79135

80-
**Note** Require to change execution policy. (Google `Set-ExecutionPolicy`).
136+
To edit profile, type `notepad $PROFILE` in PowerShell.
81137

82-
Add the following code to your profile (Run `notepad $profile` to edit) and type `ecd`.
83138

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
86149
```
87150

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.
89192

90-
[fcd](https://qiita.com/Yuhsak/items/a1f154f14e5ff871b6d2) (macOS version of this. The idea was taken from here).
193+
[CHANGELOG](CHANGELOG.md)
91194

92195
## License
93196

bin/.please-place-ebridge.exe-here

Whitespace-only changes.

bridge/eopen.ps1

Lines changed: 0 additions & 47 deletions
This file was deleted.

bridge/ewd.ps1

Lines changed: 0 additions & 28 deletions
This file was deleted.

build.bat

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@echo off
2+
3+
if "%1" == "" (
4+
call :build x86 x64 arm arm64
5+
goto :eof
6+
)
7+
8+
:build
9+
powershell -NoProfile -ExecutionPolicy Unrestricted %~dp0build.ps1 %*

build.ps1

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
$ErrorActionPreference = "Stop"
2+
3+
Set-Location "$PSScriptRoot"
4+
5+
New-Item "tmp", "dist" -ItemType Directory -Force | Out-Null
6+
function build($plartform) {
7+
if (! (Test-Path "src\$plartform")) {
8+
[Console]::Error.WriteLine("ERROR: Platform '$plartform' not defined")
9+
exit 1
10+
}
11+
12+
Set-Location src\
13+
msbuild.exe /p:Configuration="Release;Platform=$plartform" /m
14+
if ($LASTEXITCODE -ne 0) { throw "Build failed." }
15+
Set-Location ..\
16+
17+
$ebridge = "src\$plartform\Release\ebridge.exe"
18+
$version = (Get-Content src\version.h) -replace '^.*?"|".*?$',""
19+
$name="eopen-$version-$plartform"
20+
21+
Remove-Item "tmp\$name" -Recurse -ErrorAction Ignore
22+
New-Item "tmp\$name", "tmp\$name\bin" -ItemType Directory | Out-Null
23+
24+
$files = @(
25+
"README.md"
26+
"CHANGELOG.md"
27+
"LICENSE"
28+
"init.bat"
29+
"init.ps1"
30+
"init.sh"
31+
"cmd"
32+
"pwsh"
33+
"wsl"
34+
)
35+
36+
Copy-Item -Path $files -Recurse -Destination "tmp\$name"
37+
Copy-Item -Path "$ebridge" -Destination "tmp\$name\bin"
38+
39+
Compress-Archive -Path "tmp\$name" -DestinationPath "dist\$name.zip" -Force
40+
}
41+
42+
foreach($plartform in $args){
43+
build $plartform
44+
}
45+
46+
Get-ChildItem dist
47+
Write-Output "Generated"

0 commit comments

Comments
 (0)