edit_text_file
This directory provides functionality for opening commonly edited files with a user's preferred text editor. It consists of a few key files that work together:
-
edit_text_file.talon
defines a user commanduser.edit_text_file
that takes the name of a file as an argument, passes that to theuser.edit_text_file
action defined inedit_text_file.py
, waits 500ms, and then moves the cursor to the end of the file. This command is meant to be triggered using Talon voice commands. -
edit_text_file.py
implements theuser.edit_text_file
action, which opens the given file in the user's preferred text editor. It uses a platform-specific approach to open the file:- Windows: Uses
os.startfile
with the"edit"
argument which attempts to open the file in the associated text editor, and if that fails, it uses"open"
which opens a dialog to let the user choose an editor. - macOS: Uses
/usr/bin/open -t
which attempts to open the file in a text editor. - Linux: Uses
xdg-open
, which may or may not open a text editor. Ifxdg-open
isn't found, it will notify the user. It is important to note that this will fail if the user's$EDITOR
is set to a terminal editor such asnano
orvim
.
The
edit_text_file.py
file also defines theget_full_path
function. If the given file argument is not an absolute path, it will resolve it as being relative to the root of the repository. - Windows: Uses
-
edit_text_file_list.talon-list
defines theuser.edit_text_file
list. This list is used by Talon to provide a set of suggestions when using theuser.edit_text_file
command. It contains a number of common talon files and other files that a user might want to quickly edit, including some that are outside the current directory. This is why theget_full_path
function is so important.