Differences
This shows you the differences between the selected revisions of the page.
custom_commands 2020-02-07 | custom_commands 2024-10-08 (current) | ||
Line 7: | Line 7: | ||
==== Extensions ==== | ==== Extensions ==== | ||
- | * [[library_example_zip_and_upload|Pack files to ZIP archive and upload it]] | + | * [[library_example_zip_and_upload|*]] |
- | * [[extension_archive_and_download|Archive remote files to ZIP archive, download it, and optionally extract it]] | + | * [[extension_archive_and_download|*]] |
==== Tar/Gzip ==== | ==== Tar/Gzip ==== | ||
Line 36: | Line 36: | ||
<code custom-command-remote> | <code custom-command-remote> | ||
- | unzip "!" | + | unzip -o "!" |
</code> | </code> | ||
Line 42: | Line 42: | ||
<code custom-command-remote> | <code custom-command-remote> | ||
- | unzip -d "!?&Extract to directory:?.!" "!" | + | unzip -o -d "!?&Extract to directory:?.!" "!" |
</code> | </code> | ||
Line 51: | Line 51: | ||
</code> | </code> | ||
- | ==== Rar ==== | + | ==== [[rar]] Rar ==== |
<code custom-command-remote> | <code custom-command-remote> | ||
Line 70: | Line 70: | ||
test "!?Do you really want to delete ?no!" == "yes" && rm -rf !& | test "!?Do you really want to delete ?no!" == "yes" && rm -rf !& | ||
</code> | </code> | ||
+ | |||
+ | Both above solutions require a shell access. If you do not have it, use the following solution. | ||
===== [[delete_background]] Deleting on Background ===== | ===== [[delete_background]] Deleting on Background ===== | ||
Line 101: | Line 103: | ||
</code> | </code> | ||
- | ===== [[url]] URL Address of Selected File ===== | + | ===== [[time]] Changing Modification Date/Time ===== |
- | ==== Using Local Command ==== | + | |
- | Example shows how to use local custom command that maps file path to URL. | + | |
- | <code custom-command-local>!`cmd /C echo @echo off > %TEMP%\url.bat & | + | <code custom-command-remote> |
- | echo set FILE_PATH=%1 >> %TEMP%\url.bat & | + | touch -d "!?Date:!" !& |
- | echo echo https://www.example.com%FILE_PATH:home/user/public_html=~user% >> %TEMP%\url.bat` | + | </code> |
- | cmd /C %TEMP%\url.bat !/! & pause</code> | + | |
- | + | ||
- | Hints: | + | |
- | + | ||
- | * Note that the above should be entered as one line! | + | |
- | * Check custom command options //Local command// and //Use remote files//. | + | |
- | * If you want to copy the %%URL%% to clipboard instead of displaying it, replace the trailing ''& pause'' with ''| clip''. | + | |
- | * For your particular use, just replace ''%%https://www.example.com%%'' with right %%URL%% prefix, ''home/user/public_html'' with right path prefix and ''~user'' with right %%URL%% replacement (it can even be empty in some cases). | + | |
- | + | ||
- | ==== Using Remote PHP Code ==== | + | |
- | Example shows how to launch simple PHP script that maps file path to URL. | + | |
+ | ===== [[chmod]] Recursively Changing Permissions of Files or Folders only ===== | ||
+ | For changing directory permissions: | ||
<code custom-command-remote> | <code custom-command-remote> | ||
- | echo '<?="https://www.example.com".str_replace("home/user/public_html", "~user", "'`pwd`'")."/!\n"?>' | php -q | + | find ! -type d -exec chmod !?&Permissions:?755! {} \; |
</code> | </code> | ||
- | + | For changing file permissions: | |
- | Hints: | + | |
- | + | ||
- | * Note that the above should be entered as one line! | + | |
- | * Do not forget to check custom command option //Show results in terminal// or //Copy results to clipboard//, otherwise you will not get the results. You may also want to use the command for directories, check //Apply to directories// too. | + | |
- | * For your particular use, just replace ''%%https://www.example.com%%'' with right URL prefix, ''home/user/public_html'' with right path prefix and ''~user'' with right %%URL%% replacement (it can even be empty in some cases). | + | |
- | * If you do mapping like above, i.e. for server containing multiple user's homepages, you can make it universal by replacing ''user'' with ''%%'`whoami`'%%''. | + | |
- | + | ||
- | ==== Using Remote Shell Code ==== | + | |
- | + | ||
- | Another example using shell commands only, in case PHP is not available: | + | |
<code custom-command-remote> | <code custom-command-remote> | ||
- | echo 'https://www.example.com'`pwd`'/!' | sed s#home/user/public_html#~user# | + | find ! -type f -exec chmod !?&Permissions:?644! {} \; |
</code> | </code> | ||
+ | Check custom command options //Remote command// and //Apply to directories//. | ||
===== Templates ===== | ===== Templates ===== | ||
Line 189: | Line 170: | ||
==== Backup a File with Current Date and Time ==== | ==== Backup a File with Current Date and Time ==== | ||
<code custom-command-remote> | <code custom-command-remote> | ||
- | cp ! $(echo "!" | sed "s/\..*$//").$(date '+%Y-%m-%d_%H-%M').$(echo ! | awk -F"." '{ print $NF }') | + | cp ! $(echo "!" | sed "s/\.[^.]*$//").$(date '+%Y-%m-%d_%H-%M').$(echo ! | awk -F"." '{ print $NF }') |
</code> | </code> | ||
==== Rename a File with Current Date and Time ==== | ==== Rename a File with Current Date and Time ==== | ||
<code custom-command-remote> | <code custom-command-remote> | ||
- | mv ! $(echo "!" | sed "s/\..*$//").$(date '+%Y-%m-%d_%H-%M').$(echo ! | awk -F"." '{ print $NF }') | + | mv ! $(echo "!" | sed "s/\.[^.]*$//").$(date '+%Y-%m-%d_%H-%M').$(echo ! | awk -F"." '{ print $NF }') |
</code> | </code> | ||
Line 214: | Line 195: | ||
* Connect at least once from an interactive terminal (such as [[&url(putty)|PuTTY SSH client]]) to verify the destination server host key. | * Connect at least once from an interactive terminal (such as [[&url(putty)|PuTTY SSH client]]) to verify the destination server host key. | ||
* Use for example [[ui_login_authentication#forwarding|Agent forwarding]] to forward your private key to the destination server for authentication. | * Use for example [[ui_login_authentication#forwarding|Agent forwarding]] to forward your private key to the destination server for authentication. | ||
- | * Another less-secure method of authentication is use of ''[[https://sourceforge.net/projects/sshpass/|sshpass]]'' tool (see its [[&man_ref(1,sshpass)|man page]]). | + | * Another less-secure method of authentication is use of ''[[https://sourceforge.net/projects/sshpass/|sshpass]]'' tool (see its [[https://www.mankier.com/1/sshpass|man page]]). |
===== [[compare]] File Compare ===== | ===== [[compare]] File Compare ===== | ||
+ | |||
+ | Note that WinMerge and other major diff tools are supported by official [[extension_compare_files|*]]. The following is just an example how to use other diff tools. | ||
==== WinMerge ==== | ==== WinMerge ==== |