terminal-explorer

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

GPL-3.0 License

Stars
6

๐Ÿ“ข Check out the alternative flexible approach!

๐Ÿ’ก 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

๐Ÿ“ฅ 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: