sudo vi /usr/local/bin/cfc
#!/bin/bash
if [ -z "$1" ]; then
echo "No file path provided"
exit 1
fi
FILE_PATH="$1"
FILE_NAME=$(basename "$FILE_PATH")
FILE_CONTENT=$(cat "$FILE_PATH")
FORMATTED_CONTENT="**${FILE_NAME}**\n\n\`\`\`\n${FILE_CONTENT}\n\`\`\`"
# MacOSの場合:
echo -e "$FORMATTED_CONTENT" | pbcopy
echo "File content copied to clipboard"
実行権限を与えます
sudo chmod +x /usr/local/bin/cfc
拡張機能 Command Runner をインストールします
https://marketplace.visualstudio.com/items?itemName=edonet.vscode-command-runner
settings.json
"command-runner.terminal.name": "runCommand",
"command-runner.terminal.autoClear": true,
"command-runner.terminal.autoFocus": true,
"command-runner.commands": {
"copy file name and contents": "cfc ${file}",
}
keybindings.json
{
"key": "ctrl+alt+shift+c",
"command": "command-runner.run",
"args": { "command": "copy file name and contents" }
}
↓ ショートカットキーの追加