Bring file manager's copy/paste to the CLI
Terminal explorer is a files manager tool written in portable sh
that mimics the way GUI's file manager do copy/cut/paste.
- 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.
- Unix commands to process
- A clipboard managers like:
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
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.
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
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'
Special thanks to:
Made with β€οΈ by NNB