WSL2/Ubuntu 上で pbcopy を叩けるようにする
概要
- Windows 11 で WSL2 を使って Ubuntu を利用している
- SSH公開鍵をクリップボードへコピーするのに
pbcopy
コマンドを叩きたくなったが、こいつは Mac で組み込まれているコマンドのため使えない - Windows では
clip
コマンドで同じことができるらしい pbcopy
と叩いたらclip
が動作するよう、エイリアスを設定してみる
pbcopy
コマンドを叩きたくなったが、こいつは Mac で組み込まれているコマンドのため使えないclip
コマンドで同じことができるらしいpbcopy
と叩いたら clip
が動作するよう、エイリアスを設定してみるEditorConfig
https://editorconfig.org/
sindresorhus/editorconfig-sublime: Sublime Text plugin for EditorConfig – Helps developers maintain consistent coding styles between different editors
https://github.com/sindresorhus/editorconfig-sublime
open .
で Finder が開くように、コマンド入力で指定したファイルを Sublime Text で開くといった動作をしたくなったCommand Line Interface
To use subl, the Sublime Text bin folder needs to be added to the path. For a typical installation of Sublime Text, this will be located at /Applications/Sublime Text.app/Contents/SharedSupport/bin.
パスを通してあげれば subl
というコマンドが使えるようになるらしい。
# masOSで自動生成される不可視ファイルを一括削除する
function Set-removeMacFiles {
# 現在のディレクトリを取得
$currentDirectory = Get-Location
# ログファイルのディレクトリを設定
$logDirectory = "C:\Users\hi3103\OneDrive\scripts\log\"
# ログファイル名を生成 (例: "Log_2023-10-02_12-30-00.txt")
$logFileName = "Log_" + (Get-Date -Format "yyyy-MM-dd_HH-mm-ss") + ".txt"
$logFilePath = Join-Path $logDirectory $logFileName
# .DS_Store および `._` から始まるファイルを再帰的に検索し、削除
Get-ChildItem -Path $currentDirectory -Recurse -Force -File | Where-Object {
$_.Name -eq ".DS_Store" -or $_.Name -like '._*'
} | ForEach-Object {
try {
# -LiteralPath を使用して、特殊文字を含むパスも正確に削除
Remove-Item -LiteralPath $_.FullName -Force -ErrorAction Stop
$message = "Deleted: " + $_.FullName
# コンソールに表示
Write-Host $message
# ログファイルに書き込み
Add-Content -Path $logFilePath -Value $message
} catch {
$errorMessage = "Failed to delete: " + $_.FullName
$errorDetail = $_.Exception.Message
# コンソールにエラー情報を表示
Write-Host $errorMessage -ForegroundColor Red
Write-Host $errorDetail -ForegroundColor Red
# ログファイルにエラー情報を書き込み
Add-Content -Path $logFilePath -Value $errorMessage
Add-Content -Path $logFilePath -Value $errorDetail
}
}
# 完了メッセージを表示
$completionMessage = "Deletion complete. Log File: $logFilePath"
Write-Host $completionMessage
Add-Content -Path $logFilePath -Value $completionMessage
}
New-Alias -Name removemacfiles -Value Set-removeMacFiles
C:\Users\ユーザー名\OneDrive\scripts\profile\removeMacFiles.ps1
上記フォルダに格納した .ps1 ファイルを、自動で $profile
にインポートするよう設定してある。
※参考:PowerShell スクリプトを OneDrive の中で管理する
removemacfiles
と入力して実行$profile
に、用意した保存場所のスクリプトをすべて読み込む設定を記述するsublimerge.com
ドメイン自体がもう別の誰かに取られてるみたいPackage Contol の設定ファイルを編集
やること
installed_packages
の配列内に Sublimerge Pro
を追加する
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"ApacheConf",
"ayu",
"Compare Side-By-Side",
"DiffTabs",
"Emmet",
"HTML-CSS-JS Prettify",
"IMESupport",
"Sublimerge Pro",
"Package Control",
"PowerShell",
"Syntax Highlighting for Sass",
],
}
旧PCから保存したファイルを、同じ場所に複製
Sublime Text を起動
Ctrl + Alt + D
で Sublimerge が動作するか確認.md
ファイルを毎週作成しているChatGPT-4 に以下の手順でやってもらった。
macOS の Terminal 上で使える open
コマンドを、Windows でも使えるようにしたい
open .
open ./hoge.html
open
コマンドは、PowerShell で考えると Invoke-Item
が該当しそうopen
と叩いたら、 Invoke-Item
が走るようにエイリアスを設定すればいいのでは?思いつきでChatGPT(GPT-4)にやり方を聞いたら簡単そうだったのでやってみた。
#freee技術の日
とはfreee 技術の日
https://www.freee.co.jp/event/freee-tech-day-2023/