0

intellij has the cool breadcrumb that is shows on/below the editor window.

is there a cool way to get this breadcrumb in clipboard?

for example ctrl+alt+shift+C gets the file path with line number.

so is there a way to copy the breadcrumb?

basically i want to create my own live template/macro for a shortcut

  logger.info("xxx - " + breadcrumb)

i already have my live template doingth the above minus the breadcrumb part

Vojtech Ruzicka
  • 16,384
  • 15
  • 63
  • 66
Anand
  • 4,182
  • 6
  • 42
  • 54

1 Answers1

0

You can get current file path as either absolute or relative using groovyScript macro:

_editor variable is available inside the script. This variable is bound to the current editor. The _editor is an instance of EditorImpl which holds a reference to the VirtualFile that represents the currently opened file.

Therefore, the following script gets the full path of currently opened file.

groovyScript("_editor.getVirtualFile().getPath()")

Or if you want to get the path relative to the project's root:

groovyScript("_editor.getVirtualFile().getPath().replace(_editor.getProject().getBaseDir().getPath(), \"\")")

see: Current file path in Live Template

Vojtech Ruzicka
  • 16,384
  • 15
  • 63
  • 66