[Windows] Command Prompt의 Current Code page 변경

Windows에서 명령줄을 띄워서 작업할 때, 어떤 에러 메시지 등을 google에서 찾아보고 싶은 경우 같은 때, 나오는 메시지의 언어를 바꾸고 싶을 때가 있다. 이럴 때 “LANG” 환경 변수 등을 바꾸어도 그대로 에러 메시지 등이 우리말로 나온다. 요건 mingw 같은 환경에서 shell을 써도 마찬가지. 한국판 Windows를 깔면 기본이 CP949로 설정되어 에러 메시지 등이 우리말로 나오는 것인데, 다음과 같이 CHCP 명령을 이용하면 된다. 65001은 UTF-8이다.

CHCP 65001

참고: https://superuser.com/questions/269818/change-default-code-page-of-windows-console-to-utf-8

[Windows 10] Path length limit해제

Python을 설치하고 나면 맨 마지막에 “Disable path length limit”이라는 걸 하겠냐고 묻는다. Windows 10의 NTFS에서 path length limitation을 해제할 수 있게 되었다고 한다. 아래 링크들을 확인해보자.

https://stackoverflow.com/questions/51624449/python-setup-disabling-path-length-limit-pros-and-cons

https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#maximum-path-length-limitation

[Windows] Windows 10 시작 프로그램 등록

시작 -> 실행 -> shell startup 을 실행하면 시작 프로그램 폴더가 탐색기처럼 뜬다.

여기에 등록하고 싶은 시작 프로그램을 드래그 & 드랍이든, 복사하기/붙여넣기든 추가하면 된다.

추가된 시작 프로그램은 “작업관리자”의 “시작프로그램” 탭에서 사용/사용안함을 설정할 수 있다.

[Windows] Apache 2.4 + PHPv5

Apache는 apache lounge의 것을 이용하자.

https://www.apachelounge.com/download/

설치 방법은 zip 파일 내부의 ReadMe.txt를 읽어보면 충분하다. 간단히 보면 httpd.conf의 SRVROOT 경로를 설치한 폴더로 바꿔준 후, httpd.exe -k install 후 서비스 시작하면 된다.

PHP는 moniwiki를 사용하기 위해서 설치한 거라 php5를 설치했다. apache 서비스는 중지하고 설치한다.

https://windows.php.net/download/ 에서 php5를 받아 d:\php5 에 풀어준다. apache의 httpd.conf 에 다음을 추가해 준다.

AddHandler application/x-httpd-php .php

AddType application/x-httpd-php .php .html

LoadModule php5_module “d:/php5/php5apache2_4.dll”

PHPIniDir “d:/php5”

php5 설치 디렉토리 안의 php.ini-development 를 php.ini로 복사해준다.

apache 서비스를 시작!

다음과 같은 에러는 extension을 설치하지 않았을 때 나는 에러로 http://php.net/manual/it/install.windows.extensions.php 를 참조하여 해결한다.

“Call to undefined function mb_strwidth()”

해결 방법을 간단히 적으면, extension_dir = d:\php5\ext 와 같이 바꾸고, ;extension=php_mbstring.dll 과 같이 comment되어 있는 줄의 ;를 지워 comment를 해제한다.

윈도우즈 전원 설정 command tool: powercfg

컴퓨터 전원 옵션을 자꾸만 건드리는 툴, 예를 들면, 보안 프로그램이라던지, 보안 프로그램이라던지, 보안 프로그램이라던지..가 껐다켜면 자꾸 내 전원 옵션을 잠깐 안쓰면 절전모드로 바꾸게 해둔다.
제어판에서 내가 원하는 전원 옵션, 즉, 항상 켜는 전원 옵션을 만들고. 커맨드 프롬프트에서 powercfg -l 을 입려하면 만든 옵션의 GUID가 나온다.
이걸 커맨드 툴로 셋팅하려면 powercfg -SETACTIVE 하면 적용된다.
이걸 시작 프로그램에 등록하자. ㅋㅋㅋ

[Windows] touch가 필요할 때

윈도우즈 환경에서 개발하다보니, Linux 환경에서 사용하는 몇 가지 command들이 그립다.

touch 명령을 주고 싶은데, 다들 설치하라고 할 수도 없고..

Windows 환경에서 touch와 같이 날짜와 시간만 업데이트 하고 싶을 때, 해당디렉토리로 이동한 후, 다음과 같이 하면 된단다.

copy /b filename.ext +,,

이동하기 싫으면 다음과 같이 하면 된다.

copy /b D:\PATH\foo\filename.ext+,, D:\PATH\foo\filename.ext

이걸 왜 하냐고?

다음과 같은 코드 때문이다.

char *pStrTime=__TIME__;

char *pStrDate=__DATE__;

참고: http://superuser.com/questions/10426/windows-equivalent-of-the-linux-command-touch

[Git] Line ending character 관련 설정

git을 윈도우즈에서 쓸 때의 꽤 짜증나는 점은 줄바꿈 문자(CR/LF vs LF-윈도우즈에서는 CR,LF를 쓰고, Unix계열에서는 LF만 쓴다)이다.

CR,LF 문자가 바뀌면 git에서는 그냥 소스 파일 전체를 다른 파일로 여기기 때문에, 크로스 플랫폼 환경에선 매우 짜증난다. 그래서 이를 해결하기 위한 옵션이 있는데, core.autocrlf 옵션이다.

autocrlf 옵션은 세가지 값을 가질 수 있다.

1. true: “git config –global core.autocrlf true”

commit할 때 CR,LF -> LF, check out할 때 LF -> CR,LF.

2. input: “git config –global core.autocrlf input”

commit할 때만 CR,LF -> LF.

3. false: “git config –global core.autocrlf false”

그냥 그대로 쓴다. 저장소에도 CR이 저장된다.

또한, patch를 이용하는 경우에도 CR,LF와 LF 문제로 걸리적 거릴 때가 많다.

가령, format-patch를 만들면, patch 파일은 LF를 사용하게 되는데, 이걸 am으로 적용할 때도 제대로 작동하지 않는다. 같은 곳에서 그냥 연달아 format-patch HEAD^ -> reset HEAD^ -> am 0001-blah.patch를 했을 때조차 적용되지 않는 걸 보면 그냥 아주 돌아버린다.

도움을 주기 위한 옵션은 git am의 –keep-cr 이다.

참고: https://git-scm.com/book/ko/v1/Git%EB%A7%9E%EC%B6%A4-Git-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0

[Windows] BAT 파일에서 현재 시간,날짜 만들기

Stackoverflow에 외국에 맞는게 올라가 있다.

Locale 설정에 따라 달라져야 한다. 맞게 바꾸면.

set hour=%time:~0,2%

if “%hour:~0,1%” == ” ” set hour=0%hour:~1,1%

echo hour=%hour%

set min=%time:~3,2%

if “%min:~0,1%” == ” ” set min=0%min:~1,1%

echo min=%min%

set secs=%time:~6,2%

if “%secs:~0,1%” == ” ” set secs=0%secs:~1,1%

echo secs=%secs%

set year=%date:~0,4%

echo year=%year%

set month=%date:~5,2%

if “%month:~0,1%” == ” ” set month=0%month:~1,1%

echo month=%month%

set day=%date:~8,2%

if “%day:~0,1%” == ” ” set day=0%day:~1,1%

echo day=%day%

set datetimef=%year%%month%%day%_%hour%%min%%secs%

참고: http://stackoverflow.com/questions/1192476/format-date-and-time-in-a-windows-batch-script

git p4 Windows에서 쓰기

아. git-p4를 내가 다시 쓸 일이 생기다니.. OTL

Perforce는 (거지같게도) patch 파일이나 diff 파일 만드는 기능이 빈약해서 git p4 clone 해서 patch 파일을 만들어 사용하면 편하다.

사실 별로 해줄 건 없고,

Git for Windows 깔고,

p4 깔고,

git-p4.py 만 https://raw.github.com/git/git/master/git-p4.py 에서 받아다가 “C:\Program Files (x86)\Git\bin\” 아래에 넣어주면 된다.

git-p4.py 치는 거보다 git p4 로 쓰고 싶으면 “%USERPROFILE%.gitconfig” 를 아래와 같이 고쳐서 alias해주면 된다.

[alias]

p4 = !’C:\\Program Files (x86)\\Git\\bin\\git-p4.py’

기본 config variable은 다음과 같다.

git-p4.user

User specified as an option to all p4 commands, with -u
<user>
. The environment variable P4USER can be used instead.

git-p4.password

Password specified as an option to all p4 commands, with -P
<password>
. The environment variable P4PASS can be used
instead.

git-p4.port

Port specified as an option to all p4 commands, with -p
<port>
. The environment variable P4PORT can be used instead.

git-p4.host

Host specified as an option to all p4 commands, with -h
<host>
. The environment variable P4HOST can be used instead.

git-p4.client

Client specified as an option to all p4 commands, with -c
<client>
, including the client spec. 

참고: http://ericlathrop.com/2012/12/how-to-set-up-git-p4-in-windows/


[Windows] Tortoise*를 사용할 때 Icon Overlay 안보이는 문제

Windows 7 등에서 TortoiseCVS, TortoiseSVN, TortoiseGit, TortoiseHg 등을 사용할 때, 아이콘 오버레이가 안보이는 경우가 있다.

이 경우 레지스트리 문제인데, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ShellIconOverlayIdentifiers 아래에 Sub key 가 너무 많아서 그렇다. 15개 까지만 보인다고 한다.

잘 안쓰이는 Icon Overlay 항목에 그냥 “z_”를 추가시켜서 정렬했을 때 아래로 가도록 만들자. 수정 후에는 로그오프/로그인. 간단히 재부팅해도 되고~

참고 : http://stackoverflow.com/questions/1057734/tortoisesvn-icons-not-showing-up-under-windows-7