Skip to content

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

License

Notifications You must be signed in to change notification settings

NNBnh/terminal-explorer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

36 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“’ Check out the alternative flexible approach!

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 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:






Made with ❀️ by NNB

Buy Me a Coffee