'OS/linux'에 해당되는 글 22건

  1. 2022.01.18 Ubuntu 편하게 쓰기 - 긴명령 줄 불러오기 : Pet
  2. 2021.12.12 ubuntu apt 서버 변경하기
  3. 2021.12.10 git 임시로 committer, author 바꿔 commit 하기
  4. 2021.12.09 oh-my-zsh 에서 타이틀바 바꾸기
  5. 2021.12.06 vim 사용중 fugitive 에러 발생
  6. 2021.12.01 git 삭제된 파일 히스토리 보기
  7. 2021.11.30 ubuntu 7zip 사용하기
  8. 2021.04.05 linux 기존 명령 대체 명령
  9. 2021.03.25 grep 이전 라인 다음라인 같이 보기
  10. 2021.03.25 ubuntu zip 압축하기

Ubuntu 편하게 쓰기 - 긴명령 줄 불러오기 : Pet

OS/linux 2022. 1. 18. 22:23
반응형

pet : CLI Snippet Manager

https://github.com/knqyf263/pet

 

GitHub - knqyf263/pet: Simple command-line snippet manager, written in Go.

Simple command-line snippet manager, written in Go. - GitHub - knqyf263/pet: Simple command-line snippet manager, written in Go.

github.com

 

fzf 설치(명령 리스트 볼때 사용 되며, 그외 여러 명령 과 결합하여 사용됨)

https://github.com/junegunn/fzf

 

GitHub - junegunn/fzf: A command-line fuzzy finder

:cherry_blossom: A command-line fuzzy finder. Contribute to junegunn/fzf development by creating an account on GitHub.

github.com

$ sudo apt-get install fzf

 

pet 설치

$ wget https://github.com/knqyf263/pet/releases/download/v0.3.6/pet_0.3.6_linux_amd64.deb
$ dpkg -i pet_0.3.6_linux_amd64.deb

 

pet 실행

$ pet
pet - Simple command-line snippet manager.

Usage:
  pet [command]

Available Commands:
  configure   Edit config file
  edit        Edit snippet file
  exec        Run the selected commands
  help        Help about any command
  list        Show all snippets
  new         Create a new snippet
  search      Search snippets
  sync        Sync snippets
  version     Print the version number

Flags:
      --config string   config file (default is $HOME/.config/pet/config.toml)
      --debug           debug mode
  -h, --help            help for pet

Use "pet [command] --help" for more information about a command.

 

ctrl-s 키로 pet search 실행 설정하기

$ cat .zshrc
function pet-select() {
  BUFFER=$(pet search --query "$LBUFFER")
  CURSOR=$#BUFFER
  zle redisplay
}
zle -N pet-select
stty -ixon
bindkey '^s' pet-select

명령 추가 및 변경 - 설정 파일 변경(명령 옵션 사용하기 귀찮을때)

텍스트 에디터로 변경 후 저장

$ cat ~/.config/pet/snippet.toml
[[snippets]]
  description = "git show file list of commit"
  command = "git diff-tree --no-commit-id --name-only -r <revision>"
  output = ""

[[snippets]]
  description = "find files that dont contain string pattern"
  command = "egrep -riL \"copyright\" dir"
  output = ""

[[snippets]]
  description = "git find files created after date"
  command = "git log --pretty=oneline --name-status --since \"26 jul 2018\" | grep ^A"
  output = ""

[[snippets]]
  description = "gnome-control-center"
  command = "sudo env XDG_CURRENT_DESKTOP=GNOME gnome-control-center"
  output = ""

[[snippets]]
  description = "check open file before umount "
  command = "lsof +f -- /home/builder/hdd_home"
  output = ""

[[snippets]]
  description = "ssh to ssh client"
  command = "ssh builder@`echo $SSH_CLIENT | awk '{ print $1}'`"
  output = ""

 

 

 

반응형
:

ubuntu apt 서버 변경하기

OS/linux 2021. 12. 12. 10:52
반응형

kakao 서버로 변경(http://mirror.kakao.com/ubuntu/, 기본 서버는 속도가 느림)

$ sudo sed -i s/kr.archive.ubuntu.com/mirror.kakao.com/g /etc/apt/sources.list 
$ sudo apt update

변경된 서버에서 정보 받아오기

$ sudo apt update
받기:1 http://mirror.kakao.com/ubuntu focal InRelease [265 kB]
받기:2 http://mirror.kakao.com/ubuntu focal-updates InRelease [114 kB]
받기:3 http://mirror.kakao.com/ubuntu focal-backports InRelease [108 kB]
받기:4 http://mirror.kakao.com/ubuntu focal/main i386 Packages [718 kB]
받기:5 http://mirror.kakao.com/ubuntu focal/main amd64 Packages [970 kB]                                          
받기:6 http://mirror.kakao.com/ubuntu focal/main Translation-en [506 kB]
반응형
:

git 임시로 committer, author 바꿔 commit 하기

OS/linux 2021. 12. 10. 22:42
반응형

환경 변수에 committer 와 author 를 설정 하면 git 명령 실행시 참조 하게됨

commit.sh

#!/bin/sh

NEW_NAME="testtest"
NEW_EMAIL="testtest@testmail.com"
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"

git commit

기존 commit 에서 특정 이름 변경 하기(git push --force 가 가능해야함)

changeCommit.sh

#!/bin/sh

git filter-branch --env-filter '
OLD_EMAIL="oldold@old.com"
NEW_NAME="newnew"
NEW_EMAIL="newnew@new.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$NEW_NAME"
    export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$NEW_NAME"
    export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

# push modification
# git push --force --tags origin HEAD:main
반응형
:

oh-my-zsh 에서 타이틀바 바꾸기

OS/linux 2021. 12. 9. 23:45
반응형

Idle 상태

 

명령 실행시

수정내용(타이틀바에 TEST 추가)

~/.oh-my-zsh/lib/termsupport.zsh

....
-ZSH_THEME_TERM_TITLE_IDLE="%n@%m:%~"
+ZSH_THEME_TERM_TITLE_IDLE="TEST %~"

....

-  title "$CMD" "%100>...>${LINE}%<<"
+  title "$CMD" "TEST %100>...>${LINE}%<<"

 

반응형
:

vim 사용중 fugitive 에러 발생

OS/linux 2021. 12. 6. 16:56
반응형

vi 로 파일을 열때마다 아래 에러 메세지가 발생함

Error detected while processing ~/.vim/bundle/vim-fugitive/plugin/fugitive.vim:
line  470:
E1208: -complete used without -nargs
line  471:
E1208: -complete used without -nargs
line  475:
E1208: -complete used without -nargs
line  478:
E1208: -complete used without -nargs
Press ENTER or type command to continue

수정 방법

fugitive 플러그인 업데이트로 문제 수정됨, 관련 업데이트가 있었던듯...

 ~/.vim/bundle/vim-fugitive │ master 
$ git pull  
remote: Enumerating objects: 1911, done.
remote: Counting objects: 100% (1719/1719), done.
remote: Compressing objects: 100% (490/490), done.
remote: Total 1911 (delta 944), reused 1532 (delta 837), pack-reused 192
Receiving objects: 100% (1911/1911), 417.87 KiB | 681.00 KiB/s, done.
Resolving deltas: 100% (947/947), completed with 10 local objects.
From https://github.com/tpope/vim-fugitive
   0e35c9b..2064312  master          -> origin/master
 * [new branch]      double-status   -> origin/double-status
 * [new branch]      parallel-status -> origin/parallel-status
 * [new tag]         trashtest       -> trashtest
 * [new tag]         v3.3            -> v3.3
 * [new tag]         v3.4            -> v3.4
 * [new tag]         v3.5            -> v3.5
 * [new tag]         v3.6            -> v3.6
Updating 0e35c9b..2064312
반응형
:

git 삭제된 파일 히스토리 보기

OS/linux 2021. 12. 1. 18:59
반응형
$ git log --all --full-history -- <path-to-file>
반응형
:

ubuntu 7zip 사용하기

OS/linux 2021. 11. 30. 10:32
반응형
sudo apt-get install p7zip-full

 

$ 7z

7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
p7zip Version 9.20 (locale=C,Utf16=off,HugeFiles=on,8 CPUs)

Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
       [<@listfiles...>]
반응형
:

linux 기존 명령 대체 명령

OS/linux 2021. 4. 5. 10:24
반응형

파일 및 디렉토리 용량 체크

du - ncdu(디렉토리 이동하면서 확인가능)

dev.yorhel.nl/ncdu/scr

 

ls - lsd(많은 컬러와 파일 및 디렉토리에 따른 아이콘)

github.com/Peltoche/lsd

 

find - fd-find(좀 더 직관적인 명령 옵션, 컬러)

github.com/sharkdp/fd

 

cd - enhancd(부정확한 경로 입력시 기존에 이동했던 경로 리스트에서 선택)

github.com/b4b4r07/enhancd

 

grep - ripgrep(파일 별로 분리된 결과)

github.com/BurntSushi/ripgrep

반응형
:

grep 이전 라인 다음라인 같이 보기

OS/linux 2021. 3. 25. 17:50
반응형

grep -B 1 TEXT file      // 이전 라인 같이 보기

grep -A 1 TEXT file      // 다음 라인 같이 보기

grep -a 1 TEXT file      // 이전,다음 라인 같이 보기

반응형
:

ubuntu zip 압축하기

OS/linux 2021. 3. 25. 17:47
반응형

zip out.zip in1 in2

반응형
: