Sublime text: Difference between revisions

Jump to navigation Jump to search
824 bytes removed ,  Yesterday at 10:52
Line 45: Line 45:
== How to open files with your favorite editor from the terminal? ==
== How to open files with your favorite editor from the terminal? ==


1. Open your shell config file:
[[Open Files in a GUI Editor from the Terminal]]
<pre>
vi ~/.zshrc    # for zsh
vi ~/.bashrc  # for bash
</pre>
 
2. Add an alias for your editor:
<pre>
# VS Code
alias code="open -a 'Visual Studio Code'"
<pre>
 
Tip: Not sure of the exact app name? Run this to find it:
<pre>
ls /Applications/ | grep -i "visual\|cursor\|zed\|sublime"
</pre>
 
The name must exactly match the `.app` filename in `/Applications/` (without the `.app` extension).
 
3. Reload your config:
<pre>
source ~/.zshrc    # for zsh
source ~/.bashrc  # for bash
</pre>
 
 
One-liner shortcut:
<pre>
# Detect current shell and set the corresponding config file
RC_FILE="$HOME/.$(basename $SHELL)rc"
 
# Append the alias to the config file (>> appends without overwriting)
echo 'alias code="open -a Visual\ Studio\ Code"' >> "$RC_FILE"
 
# Reload the config file so the alias takes effect immediately
source "$RC_FILE"
</pre>


== How to open and create non-existent files with Sublime Text from terminal? ==
== How to open and create non-existent files with Sublime Text from terminal? ==

Navigation menu