Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nnbnh/terminal-explorer

๐Ÿ“‹ Bring file manager's copy/paste to the CLI
https://github.com/nnbnh/terminal-explorer

basher bpkg cli clipboard copy-paste file-manager posix symlink terminal

Last synced: 3 months ago
JSON representation

๐Ÿ“‹ Bring file manager's copy/paste to the CLI

Awesome Lists containing this project

README

        

> **๐Ÿ“ข [Check out the alternative flexible approach!](https://github.com/NNBnh/dotfiles/wiki/files-manager#-copy-cut-link-delete-and-rename-items)**

Terminal Explorer


Bring file manager's copy/paste to the CLI


License: GPL-3.0 Development completed

## ๐Ÿ’ก About

**Terminal explorer** is a files manager tool written in [`portable sh`](https://github.com/dylanaraps/pure-sh-bible) that mimics the way GUI's file manager do copy/cut/paste.

## โœจ Features

- **Minimum**: with exactly [**269** lines of `sh`](https://github.com/NNBnh/terminal-explorer/blob/main/bin/te) and [minimum dependencies](#dependencies).
- **Register**: you can operate in any specific register.
- **Smart cut**: after cutting the file to a new path, the file's new path will be automatically copied for future operation.
- **Customizable**: you can change the commands to set/get the clipboard, commands to copy/cut files, see more [here](#configuration).

## ๐Ÿš€ Setup

### ๐Ÿงพ Dependencies

- [Unix commands](https://en.wikipedia.org/wiki/List_of_Unix_commands) to process
- A clipboard managers like:
- [`clipb`](https://github.com/NNBnh/clipb) clipboard managers warper
- [`wl-clipboard`](https://github.com/bugaevc/wl-clipboard) for [Wayland](https://wayland.freedesktop.org)
- [`xclip`](https://github.com/astrand/xclip) or [`xsel`](http://www.kfish.org/software/xsel) for [X.org](https://www.x.org)

### ๐Ÿ“ฅ Installation

#### ๐Ÿ”ง Manually

Option 1: using `curl`

```sh
curl https://raw.githubusercontent.com/NNBnh/terminal-explorer/main/bin/te > ~/.local/bin/te
chmod +x ~/.local/bin/te
```

Option 2: using `git`

```sh
git clone https://github.com/NNBnh/terminal-explorer.git ~/.local/share/terminal-explorer
ln -s ~/.local/share/terminal-explorer/bin/te ~/.local/bin/te
```

#### ๐Ÿ“ฆ Package manager

For [Bpkg](https://github.com/bpkg/bpkg) user:

```sh
bpkg install NNBnh/terminal-explorer
```

For [Basher](https://github.com/basherpm/basher) user:

```sh
basher install NNBnh/terminal-explorer
```

> **Note** *If you can and want to port Terminal explorer to other package managers, feel free to do so.*

## โŒจ๏ธ Usage

Run `te` in the terminal:

```sh
te ACTION[REGISTER] FILES
```

or:

```sh
te PASTE[REGISTER] [COMMAND]
```

```console
ACTION:
c, y copy FILES into REGISTER's clipboard and set paste's action to copy
x, d copy FILES into REGISTER's clipboard and set paste's action to cut
l, s copy FILES into REGISTER's clipboard and set paste's action to symlink
h copy FILES into REGISTER's clipboard and set paste's action to hardlink
```

```console
PASTE:
v, V, p, P paste FILES from REGISTER's clipboard, using custom COMMAND if defined
C, Y ignore paste's action, copy FILES from REGISTER's clipboard
X, D ignore paste's action, cut FILES from REGISTER's clipboard
L, S ignore paste's action, symlink FILES from REGISTER's clipboard
H ignore paste's action, hardlink FILES from REGISTER's clipboard
```

```console
REGISTER if leave empty will use system clipboard,
otherwise it's name can be anything that doesn't include '/'.
```

Examples:

```console
~/
โ”œโ”€ 1/
โ”œโ”€ 2/
โ”œโ”€ foo
โ””โ”€ bar
```

```sh
cd ~/
te x foo # Cut foo
te ctest bar # Copy bar to 'test' register

cd ~/1/
te p # Paste foo then copy ~/1/foo
te ptest # Paste bar from 'test' register
te ptest # Paste bar from 'test' register again

cd ~/2/
te p # Paste foo from ~/1/foo
```

Result:

```console
~/
โ”œโ”€ 1/
โ”‚ โ”œโ”€ foo
โ”‚ โ”œโ”€ bar
โ”‚ โ””โ”€ bar (2)
โ”‚
โ”œโ”€ 2/
โ”‚ โ””โ”€ foo
โ”‚
โ””โ”€ bar
```

## โš™๏ธ Configuration

Terminal explorer is configured through environment variables: `export TERMINALEXPLORER_=""`

|Value|Validity|Default|Description|
|-|-|-|-|
|`TERMINALEXPLORER_CLIPBOARD_SET_COMMAND`|``|`clipb copy`|Command to set the clipboard|
|`TERMINALEXPLORER_CLIPBOARD_GET_COMMAND`|``|`clipb paste`|Command to get the clipboard|
|`TERMINALEXPLORER_COPY_COMMAND`|``|`cp`|Command to copy files|
|`TERMINALEXPLORER_CUT_COMMAND`|``|`mv`|Command to cut files|
|||||
|`TERMINALEXPLORER_TEMPORARY`|``|`/tmp/terminal-explorer`|Temporary file's location|

Examples:

```sh
export TERMINALEXPLORER_CLIPBOARD_SET_COMMAND='xclip -in -selection clipboard'
export TERMINALEXPLORER_CLIPBOARD_GET_COMMAND='xclip -out -selection clipboard'
export TERMINALEXPLORER_COPY_COMMAND='rsync --recursive --archive -hh --partial --info=stats1 --info=progress2 --modify-window=1'
export TERMINALEXPLORER_CUT_COMMAND='rsync --recursive --archive -hh --partial --info=stats1 --info=progress2 --modify-window=1 --remove-source-files'
```

## ๐Ÿ’Œ Credits

Special thanks to:
- [**File URI Specification**](https://www.freedesktop.org/wiki/Specifications/file-uri-spec) by [Freedesktop.org](https://www.freedesktop.org)
- [**SH-realpath**](https://github.com/mkropat/sh-realpath) by [Michael Kropat](https://github.com/mkropat)





---

>

Made with โค๏ธ by NNB


>
>

Buy Me a Coffee