Terminal Explorer
Bring file manager's copy/paste to the CLI
๐ก About
Terminal explorer is a files manager tool written in portable sh
that mimics the way GUI's file manager do copy/cut/paste.
โจ Features
- Minimum: with exactly 269 lines of
sh
and minimum 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.
๐ Setup
๐งพ Dependencies
- Unix commands to process
- A clipboard managers like:
๐ฅ Installation
๐ง Manually
Option 1: using curl
curl https://raw.githubusercontent.com/NNBnh/terminal-explorer/main/bin/te > ~/.local/bin/te
chmod +x ~/.local/bin/te
Option 2: using git
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 user:
bpkg install NNBnh/terminal-explorer
For Basher user:
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:
te ACTION[REGISTER] FILES
or:
te PASTE[REGISTER] [COMMAND]
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
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
REGISTER if leave empty will use system clipboard,
otherwise it's name can be anything that doesn't include '/'.
Examples:
~/
โโ 1/
โโ 2/
โโ foo
โโ bar
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:
~/
โโ 1/
โ โโ foo
โ โโ bar
โ โโ bar (2)
โ
โโ 2/
โ โโ foo
โ
โโ bar
โ๏ธ Configuration
Terminal explorer is configured through environment variables: export TERMINALEXPLORER_<SETTING>="<value>"
Value | Validity | Default | Description |
---|---|---|---|
TERMINALEXPLORER_CLIPBOARD_SET_COMMAND |
<commands> |
clipb copy |
Command to set the clipboard |
TERMINALEXPLORER_CLIPBOARD_GET_COMMAND |
<commands> |
clipb paste |
Command to get the clipboard |
TERMINALEXPLORER_COPY_COMMAND |
<commands> |
cp |
Command to copy files |
TERMINALEXPLORER_CUT_COMMAND |
<commands> |
mv |
Command to cut files |
TERMINALEXPLORER_TEMPORARY |
<path/to/file> |
/tmp/terminal-explorer |
Temporary file's location |
Examples:
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:
Made with
โค๏ธ by NNB