NobGit
public imalexnord read

ms.open

Adds Mac "Open ." command to Windows

Languages

Repository composition by tracked source files.

PowerShell
PowerShell 100%
Create file Wiki Documentation
Clone
https://nobgit.com/user/imalexnord/ms.open.git
ssh://[email protected]:2222/user/imalexnord/ms.open.git
readme.md
# MS.Open

MS.Open brings familiar macOS-style terminal conveniences to Windows.

It started with one command:

```powershell
open .
```

It now includes a small collection of useful commands for opening files, working with paths, inspecting ports, serving local files, calculating hashes, and using the clipboard from PowerShell, Command Prompt, or Windows Terminal.

## Commands

| Command | Purpose |
| --- | --- |
| `open [path]` | Open a folder, file, or URL with its default Windows application |
| `reveal <path>` | Open File Explorer and select a file |
| `mkcd <folder>` | Create a directory and enter it |
| `copypath [path]` | Copy the current or specified full path to the clipboard |
| `reload` | Reload the current PowerShell profile |
| `which <command>` | Show which command Windows or PowerShell will run |
| `paths` | Print each `PATH` entry on its own row |
| `serve [port]` | Serve the current directory over HTTP |
| `ports` | Show listening TCP ports and their owning processes |
| `killport <port>` | Stop the process listening on a port |
| `sha256 <file>` | Calculate a SHA-256 hash |
| `pbcopy` | Copy text or piped input to the clipboard |
| `pbpaste` | Print clipboard text in the terminal |
| `msopen` | Show the built-in command summary |

> `mkcd` and `reload` are PowerShell functions. The remaining commands work from PowerShell, Command Prompt, and Windows Terminal.

## Installation

### 1. Download the repository

Download or clone this repository, then place it in a permanent location, for example:

```text
C:\MS.Open
```

The folder should contain:

```text
C:\MS.Open
├── bin
├── shell
├── install.ps1
└── uninstall.ps1
```

### 2. Run the installer

Open PowerShell inside the repository folder and run:

```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\install.ps1
```

The installer:

- Adds `C:\MS.Open\bin` to your user `PATH`
- Installs the `mkcd` and `reload` PowerShell functions
- Configures both Windows PowerShell and PowerShell 7 profiles
- Creates a backup before modifying an existing PowerShell profile
- Does not require administrator privileges

### 3. Restart your terminal

Close and reopen PowerShell, Command Prompt, or Windows Terminal.

Verify the installation:

```powershell
Get-Command open
```

You should see a result pointing to:

```text
C:\MS.Open\bin\open.cmd
```

You can also run:

```powershell
msopen
```

## Usage

### Open folders, files, and URLs

Open the current directory:

```powershell
open .
```

Open the parent directory:

```powershell
open ..
```

Open another folder:

```powershell
open "C:\Projects"
```

Open a file with its default application:

```powershell
open README.md
```

Open a website:

```powershell
open https://nobgit.com
```

### Reveal a file in File Explorer

```powershell
reveal ".\build\release.zip"
```

For files, Explorer opens with the file selected. For folders, Explorer opens the folder.

### Create and enter a directory

```powershell
mkcd new-project
```

This command is available in PowerShell because changing the current directory must happen inside the active shell session.

### Copy a path

Copy the current directory:

```powershell
copypath
```

Copy the full path of a file or folder:

```powershell
copypath ".\build\release.zip"
```

The resolved path is copied to the clipboard and printed in the terminal.

### Reload the PowerShell profile

```powershell
reload
```

This reloads the current PowerShell profile without requiring a new terminal window.

### Find which command will run

```powershell
which git
```

```powershell
which open
```

This is especially useful when multiple versions of a command exist in `PATH`.

### Inspect PATH

```powershell
paths
```

Each `PATH` entry is printed separately, along with whether the location currently exists.

### Serve the current directory

Serve the current folder on the default port, `8000`:

```powershell
serve
```

Use another port:

```powershell
serve 3000
```

Then open:

```text
http://127.0.0.1:3000/
```

The server listens on `127.0.0.1` only, so it is not exposed to other devices on the network.

Press `Ctrl+C` to stop it.

### Show listening ports

```powershell
ports
```

The output includes the address, port, process ID, and process name.

### Stop the process using a port

```powershell
killport 3000
```

MS.Open displays the owning process and asks for confirmation before stopping it.

Skip confirmation:

```powershell
killport 3000 --force
```

Use `--force` carefully. The command refuses to terminate protected Windows system processes.

### Calculate a SHA-256 hash

```powershell
sha256 ".\release.zip"
```

Example output:

```text
d2c7c9f1...  C:\Projects\release.zip
```

### Clipboard commands

Copy text:

```powershell
pbcopy "Hello from Windows"
```

Copy piped output:

```powershell
Get-Content README.md | pbcopy
```

Paste clipboard text:

```powershell
pbpaste
```

## Updating

Pull or replace the repository files, then rerun:

```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\install.ps1
```

The installer safely refreshes the `PATH` entry and PowerShell profile integration without duplicating them.

## Uninstall

Run:

```powershell
powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\uninstall.ps1
```

The uninstaller:

- Removes the MS.Open `bin` folder from your user `PATH`
- Removes the MS.Open block from Windows PowerShell and PowerShell 7 profiles
- Leaves the repository files in place

Restart the terminal after uninstalling. You can then delete the MS.Open folder.

## Requirements

- Windows 10 or Windows 11
- Windows PowerShell 5.1 or PowerShell 7
- `Get-NetTCPConnection` for the `ports` and `killport` commands

## Security notes

- `serve` binds only to `127.0.0.1`
- `killport` asks for confirmation unless `--force` is supplied
- Installation modifies only the current user's `PATH`
- Existing PowerShell profiles are backed up before modification