15,028
edits
| Line 41: | Line 41: | ||
</pre> | </pre> | ||
== How to open files with your favorite editor from the terminal? == | |||
1. Open your shell config file: | |||
<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> | |||
RC_FILE="$HOME/.$(basename $SHELL)rc" | |||
echo 'alias code="open -a Visual\ Studio\ Code"' >> "$RC_FILE" | |||
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? == | ||