2016년 7월 16일 토요일

git bash 홈 디렉토리 변경

git bash 를 실행하면 홈디렉토리가 "C:\Users\윈도사용자이름" 으로 된다.
cygwin 과 홈디렉토리를 같이 쓰고 싶어 다음과 같이 ~/.bashrc 파일을 수정했다.

계정 명은 user 이다.

로그인

$ echo $HOME
/c/Users/user # git bash 의 기본 홈 디렉토리

$ pwd
/c/Users/user

$ vi ~/.bashrc
NEW_HOME="/d/cygwin/home/user" #cygwin 의 홈 디렉토리
cd "$NEW_HOME"
[ -f .bashrc ] && . .bashrc
export HOME="$NEW_HOME"

다시 로그인 하면

$ echo $HOME
/d/cygwin/home/user

$ pwd
/d/cygwin/home/user

주의:
1. git bash 와 cygwin 은 절대 경로 지정 방식이 다르기 때문에
.bashrc 안에서 절대 경로 지정에 주의 해야 한다.
(cygwin 쪽 절대 경로명 앞에 /cygdrive 이 더 붙어있다.)
2. 환경 변수 및 환경 변수 값이 git bash 일 때와 cygwin 일 때 다르다.
즉, 홈 디렉토리가 같아질 뿐 다른 환경은 다 다르다.

2016년 7월 10일 일요일

tig: revision graph 표시 이상

gnome terminal 에서 tig 을 하면 표시에 문제가 없지만
teraterm 으로 ssh 연결해서 tig 을 하면 리비젼 그래프에서
├, │등의 라인 그래픽이 이상히게  표시된다.

다음과 같은 코드를 처리 못하는것 같다.
----------------------------------------------------------------------
^[[34mM^[(0^[[0m^[[35mqk^[(B^[[0m^[[35m ^[(B^[[0;1m
----------------------------------------------------------------------

일단 다음과 같이 추가하면 default 보다는 괜찮게 나온다.
$ cat ~/.tigrc
set line-graphics = ascii # 또는 utf-8

ascii 나 utf-8 로 설정하면 다음과 같이 나온다.
----------------------------------------------------------------------
^[[34mM^[[35m-.^[[35m ^[(B^[[0;1m
----------------------------------------------------------------------

2016년 7월 5일 화요일

conemu 설정

160619 빌드 기준

# 첫 실행시 first configuration 에서
1. settings 저장 위치
   portable 로 사용할거라 실행파일 디렉토리를 선택한다.
   
2. startup task
   주로 Git bash 용이니 {Bash::Git bash} 를 선택한다.

3. color scheme
   [<Standard VGA>]


# 세팅
Win + alt + p 로 Settings 창을 연다.

1. 폰트
Settings > Main
    Main console font
    [Bitstream Vera Sans Mono]

    [v] Alternative font
    [맑은 고딕]
    Unicode ranes
    [CJK: 2E80-9FC3;AC00-D7A3;F900-FAFF;FE30-FE4F;FF01-FF60;FFE0-FFE6;] [Apply]

* 영어는 'Bitstream Vera Sans Mono' 로 한글은 '맑은 고딕'으로 표시한다.
* http://www.dafont.com/bitstream-vera-mono.font

Settings > Main>Appearance
    Scrollbar
    (*) Show

Settings > Startup
    (*) Specified named task
       [{Bash::Git bash}

Settings > Startup > Tasks
    [+] 를 눌러 새 그룹을 만든다.
    이름
    [Bash::CygWin bash]
    명령
    [set CHERE_INVOKING=1 & Cygwin설치경로\bin\sh.exe --login -i -new_console:C:"%ConEmuDir%\..\cygwin64\Cygwin.ico"]

Settings > Features > Colors
    Schemes: [<Standard VGA>]

* first configuration 에서 고른 스킴이 맘에 안들면 여기서 바꾼다.

Settings > Integration
    ConEmu Here
    Menu item: [ConEmu Here - Git bash]
    Command: [/single -run {Git Bash}]
    Icon file:   [D:\Portables\ConEmuPack\ConEmu64.exe,0]
    [Register] 를 누른다.

Settings > Keys & Macro > Mouse
    Mouse options
        [] Send mouse events to console
    Mouse button actions        Right: [Paste]
        Middle: [<None>]


# 그 밖에
* 한글 관련 설정
* first configuration 을 다시 띄우려면 설정파일의 이름을 바꾼다(또는 지운다).

2016년 6월 29일 수요일

indent printf

#define iprintf(fmt, ...) printf("%*s" fmt, 2*depth, "", ##__VA_ARGS__)
int depth;

void print_level()
{
        if (depth > 4)
                return;

        iprintf("level %d\n", depth);

        ++depth;
        print_level();
        --depth;

        iprintf("level %d\n", depth);
}

print_level();

level 0
  level 1
    level 2
      level 3
        level 4
        level 4
      level 3
    level 2
  level 1
level 0

hex dump

#include <stdio.h>
#include <inttypes.h>

inline char nibble(char n)
{
        return n + (n > 9 ? 'a' - 10 : '0');
}

static void dump(const void *data, unsigned len, const char *ind)
{
#define DUMPW  16
#define ZBASE (DUMPW * 3)

        if (!data) return;
        if (!ind) ind = "";

        char buf[DUMPW * 4 + 1];
        const int8_t *d = (const int8_t *)data;
        unsigned lines = (len + DUMPW - 1) / DUMPW;
        unsigned l, p, z;

        for (l = 0; l < lines; ++l) {
                for (p = z = 0; z < DUMPW; ++z) {
                        uint32_t c = *d++;
                        buf[ZBASE + z] = (0x20 <= c && c <= 0x7e) ? c : '.';
                        buf[p++] = nibble((c >> 4) & 0xF);
                        buf[p++] = nibble(c & 0xF);
                        buf[p++] = ' ';
                        if (--len == 0)
                                break;
                }
                //for (; p < ZBASE; ++p) buf[p] = ' ';
                memset(buf + p, ' ', ZBASE - p);
                buf[ZBASE + z + 1] = 0;
                printf("%s%s\n", ind, buf);
        }
}

2016년 6월 14일 화요일

tip: git push

~/.bashrc
--------------------------------------------------------------------------------
alias gerrit_push='git push origin HEAD:refs/for/`git branch | sed -n "/^\*/{s/..//;p}"`'
alias git_push='git push origin `git branch | sed -n "/^\*/{s/..//;p}"`'
--------------------------------------------------------------------------------

2016년 5월 31일 화요일

vim: grep 결과 컬러링

set grepprg=grep\ --color=always\ --exclude=tags\ --exclude=.git\ -n\ $*\ /dev/null
" --color=always: grep 결과에 색을 입혀준다.
" --exclude=GLOB: 매치된는 이름의 파일은 검색하지 않음
" :grep abc -wrn .  처럼 사용



참고
http://stackoverflow.com/questions/12764999/colorizing-the-output-of-make-grep-etc-in-vim