code <filename>
VSCODE_IPC_HOOK_CLI
#!/bin/bash
# Find the most recent IPC socket
export VSCODE_IPC_HOOK_CLI=$(ls -t /run/user/$(id -u)/vscode-ipc-*.sock 2>/dev/null | head -1)
# Get the path to the VS Code CLI executable
vscode_code=$(ls -td ~/.vscode-server/cli/servers/*/server/bin/remote-cli/code 2>/dev/null | head -1) # When VS Code is available
if [ -S "$VSCODE_IPC_HOOK_CLI" ] && [ -n "$vscode_code" ]; then if [ $# -eq 0 ]; then # Running `code` with no arguments often just exits silently, # so prompt the user to specify a file when invoked as an editor echo "When using VS Code, please specify a file: editor <filename>" exit 1 fi # VS Code may be hidden behind other windows or take a moment to surface echo "Opening in VS Code..." # --wait blocks until the file is closed in VS Code "$vscode_code" --wait "$@" >/dev/null 2>&1 exit $?
else # If VS Code isn't available, fall back to another editor (nano, vim, etc.) nano "$@"
fi
#!/bin/bash
# Find the most recent IPC socket
export VSCODE_IPC_HOOK_CLI=$(ls -t /run/user/$(id -u)/vscode-ipc-*.sock 2>/dev/null | head -1)
# Get the path to the VS Code CLI executable
vscode_code=$(ls -td ~/.vscode-server/cli/servers/*/server/bin/remote-cli/code 2>/dev/null | head -1) # When VS Code is available
if [ -S "$VSCODE_IPC_HOOK_CLI" ] && [ -n "$vscode_code" ]; then if [ $# -eq 0 ]; then # Running `code` with no arguments often just exits silently, # so prompt the user to specify a file when invoked as an editor echo "When using VS Code, please specify a file: editor <filename>" exit 1 fi # VS Code may be hidden behind other windows or take a moment to surface echo "Opening in VS Code..." # --wait blocks until the file is closed in VS Code "$vscode_code" --wait "$@" >/dev/null 2>&1 exit $?
else # If VS Code isn't available, fall back to another editor (nano, vim, etc.) nano "$@"
fi
#!/bin/bash
# Find the most recent IPC socket
export VSCODE_IPC_HOOK_CLI=$(ls -t /run/user/$(id -u)/vscode-ipc-*.sock 2>/dev/null | head -1)
# Get the path to the VS Code CLI executable
vscode_code=$(ls -td ~/.vscode-server/cli/servers/*/server/bin/remote-cli/code 2>/dev/null | head -1) # When VS Code is available
if [ -S "$VSCODE_IPC_HOOK_CLI" ] && [ -n "$vscode_code" ]; then if [ $# -eq 0 ]; then # Running `code` with no arguments often just exits silently, # so prompt the user to specify a file when invoked as an editor echo "When using VS Code, please specify a file: editor <filename>" exit 1 fi # VS Code may be hidden behind other windows or take a moment to surface echo "Opening in VS Code..." # --wait blocks until the file is closed in VS Code "$vscode_code" --wait "$@" >/dev/null 2>&1 exit $?
else # If VS Code isn't available, fall back to another editor (nano, vim, etc.) nano "$@"
fi
chmod +x ~/bin/editor
chmod +x ~/bin/editor
chmod +x ~/bin/editor
# Add ~/bin to PATH (if not already)
export PATH="$HOME/bin:$PATH" # Register as the default editor
export EDITOR="$HOME/bin/editor"
export VISUAL="$HOME/bin/editor"
# Add ~/bin to PATH (if not already)
export PATH="$HOME/bin:$PATH" # Register as the default editor
export EDITOR="$HOME/bin/editor"
export VISUAL="$HOME/bin/editor"
# Add ~/bin to PATH (if not already)
export PATH="$HOME/bin:$PATH" # Register as the default editor
export EDITOR="$HOME/bin/editor"
export VISUAL="$HOME/bin/editor"
git rebase -i
Ctrl+x, Ctrl+e
Ctrl+X, Ctrl+E
editor file.txt - Open files with code <filename> from external terminals like iTerm2, Alacritty, or WezTerm
- Use VS Code as the editor for git commit or crontab -e, but automatically fall back to another editor when VS Code isn't running - Controlling VSCode From Tmux | Vinnie dot Work
- Set up code command line usage in external terminal | microsoft/vscode-remote-release#3983 - git commit — Editing commit messages
- git rebase -i — Interactive rebase operations
- crontab -e — Editing crontabs
- Ctrl+x, Ctrl+e — Bash/Zsh command-line editing
- Claude Code's Ctrl+X, Ctrl+E — Launching an external editor for prompt input