Last active
August 24, 2019 15:17
-
-
Save snipsnipsnip/14332 to your computer and use it in GitHub Desktop.
starts windows cmd in short path (requires ruby)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ruby -x "%~f0" %* | |
@exit /b | |
#!ruby -Ks | |
require 'Win32API' | |
GetShortPathName = Win32API.new('kernel32', 'GetShortPathName', 'ppi', 'i') | |
def get_short_path_name(path) | |
len = GetShortPathName.call(path, nil, 0) | |
raise if len.zero? | |
buffer = "\0" * len | |
GetShortPathName.call(path, buffer, len) | |
buffer.tr('/', '\\') | |
end | |
Dir.chdir get_short_path_name(Dir.pwd) | |
exec ENV['COMSPEC'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment