# how to make a shortcut at toolbar in lyx?

I'm sorry my english is bad. how to add a shorcut at toolbar in lyx?? so that If I klick the shorcut, I can connect to the TortoiseSVN, just shorcut(seemlessly) thanks.

-
pleae,anyone would help me? I need it for my graduate. thanks for help. –  Verly Apr 3 '11 at 16:30

This turns out not to be straight-forward at all. You need to do two things: create a new LyX command, and then create new menu item where you want it to appear.

First, some pointers:

LyX user interface and command files are stored in the ui and commands directories in:

• ~/.lyx on Linux
• %USERPROFILE%\AppData\Roaming\LyX16\Resources on Windows.

These settings are per-user, and it's generally not recommended to mess with the global settings. For reference, the equivalent global settings directories are in:

• /usr/share/lyx on Linux (might be different depending on your distribution)
• %PROGRAMFILES%\Lyx16 on Windows.

What you need to do:

1. Define a new command in your per-user commands directory in a file default.def (create it if it doesn't exist, including the commands directory). Your command will look something like:

\define "my-command" "vc-command <flags> \"path-to-command\" \"command-to-run\""

• Note that you need to escape double quotes within the command definition as they delimit LyX commands and their arguments.

• The <flags> can be one or more of UDIRM (no flags, need loaded document, mark document "dirty", reload after execution, ask for user input). Combine as needed.

• Within path-to-command you might use $$p to denote the current document path, and in command-to-run you can additionally use $$i and m which will be substituted with the current document or message, respectively. For the full syntax, you might want to look at LFUN.lyx at the doc directory in your installation, or choose Help->LyX functions from the program itself.

In your case, you will probably have something like:

\define "svn-commit" "vc-command D \"path-to-svn.exe\" \"svn commit %%i\""

2. With the command done, you will need to create a menu item for it in the interface. You can choose between menu items, toolbar items and context menus. Full treatment of the syntax will take a lot of space here, so I defer you to take a look at stdtoolbars.inc, stdmenus.inc, stdcontext.inc to see how the syntax looks like. Something that should work for you:

• Copy the default.ui file from the global ui directory to the local one.
• Create a new "mymenu.uifile in the localui directory. In it, you'll have something like: Toolbar "my-toolbar" "My toolbar" Item "SVN Commit" "svn-commit" ... End

Check one of the stdtoolbars.inc file in the global ui directory to see how the syntax looks like.

• Edit your local default.ui and add the following line below the other includes:

Include "mymenu.ui"


Further down, add your toolbar in the Toolbars` section somewhere. The file has in-line instructions for some appearance options.

3. Now, you are ready to start LyX. Do so, and notice there are no changes in the appearance. Not to worry -- you need to tell LyX to use your own customized UI file instead of the standard one. The user interface selection is naturally under Look & Feel->User Interface in LyX preferences. Choose your new file, restart LyX, and keep your fingers crossed.

More things to do:

• You might also want to assign a keyboard shortcut to your custom commands, and you can do so in LyX preferences, under Editing->Shortcuts.

At this point you are probably discouraged enough and decided this is not worth the hassle. I'm tempted to agree with you, and found that a handy opened command line window / Unix shell is far more convenient than messing with UI configuration files.