Skip to content

Instantly share code, notes, and snippets.

@f000
Created January 26, 2015 21:05
Show Gist options
  • Select an option

  • Save f000/ec6683c799d95ef9fb54 to your computer and use it in GitHub Desktop.

Select an option

Save f000/ec6683c799d95ef9fb54 to your computer and use it in GitHub Desktop.
TextMate 2 – Copy current file path to clipboard
#!/usr/bin/env bash
[[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
echo -n "$TM_FILEPATH" | pbcopy
echo "Path $TM_FILEPATH copied to clipboard."
@f000

f000 commented Jan 26, 2015

Copy link
Copy Markdown
Author
  1. Open Bundles/Edit Bundles...
  2. Press Cmd+N to create New Bundle
  3. Press Cmd+N to create Command
  4. Paste the code above to the bundle editor and set Input: Nothing, Output: Show in Tool Tip and set Key Equivalent to something like Cmd+Shift+C
  5. done

@GuiSim

GuiSim commented Feb 26, 2015

Copy link
Copy Markdown

Note that Cmd + Shift + C will not work in Java files as it conflicts with the Java Bundle Command "Copy Fully Qualified Class Name".

This can be avoided by using another shortcut for either the "Copy Current File Path" command or the "Copy Fully Qualified Class Name" command.

Thanks for this snippet, very useful.

@loadedsith

Copy link
Copy Markdown

thanks!

@ccmcbeck

Copy link
Copy Markdown

Nice.
Cmd + Shift + C conflicts with TextMate | Go | Computer
I use Alt + C

@ahmedfahmy94

Copy link
Copy Markdown

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment