Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

為 Windows 右鍵選單加上類似 Linux 的 tail -f 功能

看日誌時最順手的莫過於 Linux 的 tail -f,能即時追蹤檔案更新。在 Windows 上其實不必安裝額外工具,PowerShell 的 Get-Content -Wait 就能做到,再透過登錄檔把它掛到右鍵選單,對任何檔案都能一鍵開啟即時監看。

匯入以下登錄檔即可:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\shell\tail -f]
"Icon"="C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe"

[HKEY_CLASSES_ROOT\*\shell\tail -f\command]
@="C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe Get-Content -Wait '%1'"

由於預設的 CMD 視窗寬度與行數都偏小,追日誌時看沒幾行就滿了,建議一併把主控台視窗尺寸調大:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Console]
"ScreenBufferSize"=dword:012c0078
"WindowSize"=dword:001e0078

匯入後重新整理或重開檔案總管,右鍵選單就會多出「tail -f」項目。這算是把 Linux 的習慣無縫搬進 Windows 的小技巧。

Copyright © Linux教程網 All Rights Reserved