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 = ""

 

 

 

반응형
: