Working with files
Custom commands
Save commands you run often, with patterns that fill in file names, paths and session details.
A custom command is a command line you save once and run from a menu, a toolbar button or a key. Patterns in it are replaced when it runs: with the selected file names, the current path, the host name, and so on. A command can run on the server or on your own computer.
Run a custom command
Section titled “Run a custom command”- Commands that act on files are in Files › File Custom Commands and in the file context menu. Select the files first.
- Commands that do not need files are in Commands › Static Custom Commands.
- Options › Toolbars › Custom Command Buttons shows a toolbar with one button per command.
To run a one-off command without saving it, choose Enter… at the bottom of either menu. After that, the menu also offers to run that command again.
linscp ships with a few examples, among them commands to make a file
executable and run it, touch files, pack and unpack tar archives, and
grep for a word.
Create a command
Section titled “Create a command”- Open Options › Preferences › Integration › Commands.
- Click Add… (or the arrow next to it, then Add Custom Command…).
- Fill in Description, the name shown in menus.
- Write the Custom command, for example
du -sh "!". - Choose Remote command to run it on the server, or Local command to run it on your computer.
- Set the options you need (below) and, if you like, a Keyboard shortcut.
- Click OK.
Use Edit…, Remove, Up and Down to maintain the list. The order is the order of the menus.
Options
Section titled “Options”- Apply to directories – also run for selected directories, not only files.
- Execute recursively – run for every file inside the selected directories.
- Show results in terminal – open a window with the output.
- Copy results to clipboard – put the output on the clipboard.
- Use remote files – for a local command started from the remote panel: pass the remote paths to the command instead of downloading the files first.
Without Use remote files, a local command on remote files works on temporary copies. linscp downloads the files, runs the command, and uploads any file the command changed.
Patterns
Section titled “Patterns”| Pattern | Replaced with |
|---|---|
! |
One file path. The command runs once per selected file. Put it in quotes. |
!& |
All selected paths, quoted and separated by spaces. The command runs once. |
!/ |
The current remote directory, ending in /. |
!\ |
The current local directory. |
!^! |
A file in the local panel, to pair with a remote file (Commander interface). |
!@, !U, !P, !# |
Host name, user name, password (if known) and port of the session. |
!N |
The site name. |
!K |
The path of the session’s private key. |
!S, !E |
A session URL; !E adds the advanced settings. Useful to start linscp-cli on the same server. |
!?Question?default! |
A value you type when the command runs. |
!`cmd` |
The output of a local command. |
!! |
A literal !. |
Click patterns in the dialog for the full list.
Examples
Section titled “Examples”# Remote: archive the selected directories into one filetar -czf "!?Archive name:?backup.tgz!" !&
# Remote: show disk usage of each selected itemdu -sh "!"
# Local: compare a local and a remote file with Meldmeld "!^!" "!"