Optional auto execution of command / macro on startup

You have encountered a problem using Far Manager? Here you can get help.
Post Reply
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Optional auto execution of command / macro on startup

Post by kamil »

When I'm starting Far, I want to decide (on the command line) to auto-execute a macro.

Something like flags = "RunAfterFARStart", but optional - controlled from the command line.

Is it possible?
Shmuel
Posts: 6834
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 530 times

Optional auto execution of command / macro on startup

Post by Shmuel »

1. Could you show a real-life example where it would be useful?
2. A macro may start with a message box asking the user if he wants to execute that macro so the user can either cancel or continue the execution.
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Optional auto execution of command / macro on startup

Post by kamil »

My system's environment is set via Far's "Environment Manager" plugin.

When Windows starts I want to auto-start a specific command, using that environment.

So basically I want to start Far and from within Far launch that command.

But when I manually start Far later (when the system is already running) I don't want it to auto-start that command anymore.
Shmuel
Posts: 6834
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 530 times

Optional auto execution of command / macro on startup

Post by Shmuel »

You can add an environment variable for that purpose, e.g. "MySystemStarted".
Your auto-starting macro first checks that variable:
if it is already set then the macro returns, otherwise it sets that variable and runs the plugin command.
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Optional auto execution of command / macro on startup

Post by kamil »

Perhaps there is a way to invoke a specific macro from the command line that starts Far?

Or maybe I can check the command line switches that Far was started with, from inside a lua script?
ccaid
Posts: 908
Joined: Fri 12 Jun, 2009 16:04
Has thanked: 24 times
Been thanked: 6 times

Optional auto execution of command / macro on startup

Post by ccaid »

kamil,

Code: Select all

>far /?
..........
 -ma  Do not execute auto run macros.
..........
Фар делают добрые люди
Shmuel
Posts: 6834
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 530 times

Optional auto execution of command / macro on startup

Post by Shmuel »

kamil wrote: Sat 27 Apr, 2019 14:38 Perhaps there is a way to invoke a specific macro from the command line that starts Far?
Yes, it is described in Far Help, e.g.: far lua:far.Message"Hello" or far lua:@mypath\myfile.lua
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Optional auto execution of command / macro on startup

Post by kamil »

That's perfect - thank you!
kamil
Posts: 44
Joined: Fri 13 Apr, 2012 19:19
Has thanked: 8 times

Optional auto execution of command / macro on startup

Post by kamil »

BTW, I did check in the Command Line switches of Far Help, but it wasn't there.
Shmuel
Posts: 6834
Joined: Thu 23 Mar, 2006 21:36
Location: Israel
Has thanked: 41 times
Been thanked: 530 times

Optional auto execution of command / macro on startup

Post by Shmuel »

kamil wrote: Sat 27 Apr, 2019 15:06 I did check in the Command Line switches of Far Help, but it wasn't there.
It is in the last paragraph of that page.
Post Reply

Return to “Support and Troubleshooting”