
Terminal Productivity
- ssh without password
- rsync
- What’s the version of my OS?
- Combine multiple commits into one
- git
-u
flag - dig
+trace
- diff와 patch
- Port Forwarding
- nload
- Typora parser
- bundle exec jekyll serve
- tar with excludes
ssh without password
$ ssh-copy-id -i ~/.ssh/id_rsa.pub -p 300XX XXX@10.12.XX.XX
rsync
두 디렉토리 동기화
$ rsync -avzh \
--dry-run \
--progress \
~/Documents/BACKUPZ/2020/ ./2020/
앞에가 src, 뒤가 dest 이며, dry-run
실행 구문이다. --progress
는 412 files to consider
표시.
What’s the version of my OS?
Linux1
Open a terminal and type uname -a
. This will give you your kernel version, but might not mention the distribution your running. To find out what distribution of linux your running (Ex. Ubuntu) try lsb_release -a
or cat /etc/*release
or cat /etc/issue*
or cat /proc/version
.
Combine multiple commits into one
$ git rebase -i HEAD~4
HEAD
다음에는 전체 갯수를 지정한다. 총 4개의 최신 커밋이 표시된다.
pick ae536d3 2 <---- older commit
s cf6a7c7 3
s bc15ec6 4
pick 39d9628 5 <---- newer commit
s, squash
커밋 로그만 수정할때는 r
을 사용하면 된다. (e
로 하면 --continue
로 다시 한 번 진행 필요)
GitHub Desktop에서는 push 하기 전 Undo Commit을 지원한다. CLI에서는 push 이후에도 리셋이 가능하다.
# Pager를 사용하지 않도록 최초 설정
$ git config --global core.pager cat
# 커밋 로그 조회
$ git log --oneline
818c17c (HEAD -> main) 2
d60ac7b 1
$ git reset --soft HEAD~1
--soft
는 커밋만 제거되고 수정사항은 파일에 그대로 남아 있지만 --hard
로 진행할 경우 수정사항도 모두 초기화되기 때문에 주의가 필요하다. 이후 push로 마무리 하면 되는데 rebase를 했기 때문에 failed to push가 발생하고 --force
로 진행해야 한다.
$ git push --force
참고로 git revert
는 revert 내역을 명시적으로 남기면서 커밋을 추가하기 때문에 커밋 로그를 정리하는 용도로는 적절치 않다.
git -u
flag
첫 push 할 때 다음과 같이 진행하는데:
$ git push -u origin master
여기서 -u
flag는 local branch와 remote branch를 자동으로 연결한다. 그렇지 않으면 매 번 origin과 브랜치명을 기입해주어야 한다. 그 다음 부터는 옵션없이 git pull
, git push
가 가능하다.
기타 브랜치 명령:
# 브랜치 확인
$ git branch -va
# 현재 브랜치명 변경:
$ git branch -M master
dig +trace
$ dig +trace likejazz.com
+trace
는 DNS 질의 과정을 root dns 부터 모두 표시해준다.
diff와 patch
다음과 같이 변경 사항을 생성한다.
$ diff -u a-original/a.py a-patched/a.py
--- a-original/a.py 2022-05-11 10:07:21.000000000 +0900
+++ a-patched/a.py 2022-05-11 10:07:42.000000000 +0900
@@ -1,4 +1,4 @@
aaa
bbb
-ccc
+ddd
ddd
> a.patch
를 이용해 패치 파일로 저장한 다음, 다음과 같이 적용할 수 있다.
$ patch -p0 < a.patch
a-original/a.py
에 패치가 적용된다.
Port Forwarding
$ ssh -N -L 7860:10.17.120.XX:7860 airlab-xxx@10.12.54.XX -p 30001
localhost:7860
으로 접속하면 10.12.54.XX:30001의 ssh를 통해 10.17.120.XX:7860으로 연결된다.
ssh 접속 via proxy
$ cat ~/.ssh/config
Host sshuser-vpn
Hostname 10.17.119.XX
Port 2222
User sshuser
IdentityFile /Users/HXXXXXXX/.ssh/id_rsa_rapids_docker
ProxyCommand ssh -W 10.17.119.XX:2222 airlab-xxx@10.12.54.XX -p 30001
$ ssh sshuser-vpn
10.12.54.XX를 통해서 10.17.119.XX:2222로 ssh 접속한다.
nload
네트워크 모니터링 $ sudo apt install nload
Device는 eth를 택하도록 화살표로 선택하고 F2
옵션에서 Unit for traffic numbers: Human Readable (Byte)에서 TAB
으로 선택, F5
로 저장
Typora parser
https://github.com/PegasisForever/typora-parser
footnotes가 포함된 행에 superscript가 함께 있을 경우 제대로 처리되지 않는 문제가 있다. src/inlines/inlineNode.ts
에서 아래 부분 패치:
const nodePrecedenceGroups = [
[RawHTMLNode, AutolinkNode, CodeSpanNode, EmojiNode],
[HighlightNode, SubScriptNode, SuperScriptNode, FootnoteNode],
[LinkNode.LinkNode],
[EmphNode.EmphNode],
]
footnotes 순서를 superscript에 포함하여 패치. 빌드 과정:
$ npm i && \
chmod +x ./build/bin/typoraExport.js && \
./build/bin/typoraExport.js -g ./tags.txt -o ./ch5.html "5. test.md" && \
open ./ch5.html
bundle exec jekyll serve
macOS를 업데이트 할 때 마다 실행에 문제가 있다.
macOS 기본 ruby에 system libraries를 설치할 수 없기 때문인데 Ventura에서 다음과 같이 해결했다.
# rvm 설치
$ curl -sSL https://raw.githubusercontent.com/rvm/rvm/master/binscripts/rvm-installer | bash -s stable
$ rvm install "ruby-3.1.2"
$ brew install openssl@1.1
# https://stackoverflow.com/a/31516586
$ bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl@1.1)/include
# https://stackoverflow.com/a/70916831
$ bundle add webrick
# runme.sh
$ bundle exec jekyll serve
tar with excludes
디렉토리 제외 설정은 tar 옵션 맨 앞에, cvf
는 반드시 하이픈 부여 필요.
$ tar --exclude='*.json' --exclude='FastChat/wandb' --exclude='FastChat/output' -cvf FastChat.tar FastChat/
Last Modified: 2023/05/04 16:28:28