ã¹ãã¼ãã³ã³ãã³ãäºæ¥é¨ã§éçºãæ
å½ãã¦ããå
çã§ãã
ã¢ããã³ãã«ã¬ã³ãã¼9æ¥ç®ã¨ãããã¨ã§ãghq fzf ezaã§ãã¼ã«ã«ãªãã¸ããªã楽ãã管çããæ¹æ³ããç´¹ä»ãã¾ãã
ãã®è¨äºã®å¯¾è±¡è
- ãã¼ã«ã«ã§ã®ãªãã¸ããªç®¡çã«æ©ãã§ãã人
- ä½æ¥ã®ãã³ã«ãã¼ã«ã«ãªãã¸ããªãæ¢ãã¦ãã人
- ã¿ã¼ããã«ããã£ã¨ä½¿ããããã«ãªããã人
- zshã使ç¨ãã¦ãã人 (ä»ã§ãå¯è½ã§ãããä»åã¯zshã®ã¿ã®ç´¹ä»ã«ãªãã¾ã)
ã³ããã§è¨å®ã§ããããã«ãã¦ããã®ã§ãåãæããããããã¨æãã¾ãã
ãã²ææ¦ãã¦ã¿ã¦ãã ããã å®æç³»ã¯ãããªæãã§ãã
ãã¼ã«ã«ãªãã¸ããªãä¸ç®æã§ç®¡çããã¿ã¼ããã«ä¸ã§control(^) + f
ã使ã£ã¦æ¤ç´¢ç§»åã§ãã¾ãã
ããã§ã¯æ©éå§ãã¦ããã¾ãããï¼
Git管çã¨ãã£ã¬ã¯ããªç§»å
å®æ½ãªã¹ã
- ghq fzf ezaã®ã¤ã³ã¹ãã¼ã«
- ãã©ã³ãã¨ã¢ã¤ã³ã³è¨å®
- zshã®è¨å®
- â ezaã®è¨å®
- â¡ghq fzf eza çµã¿åãã
- â¢cd + ls ã®è¨å® (cdã®å¾ã«lsããã)
- â£ã¿ã¼ããã«èµ·åæã«ãã£ã¬ã¯ããªç§»åãããã
ghq fzf ezaã®ã¤ã³ã¹ãã¼ã«
â åèãªã³ã¯
https://github.com/x-motemen/ghq
https://github.com/junegunn/fzf
https://github.com/eza-community/eza
- åtoolã®ã¤ã³ã¹ãã¼ã«
- ghqã§ç®¡çããrootãã£ã¬ã¯ããªãè¨å®(ãã®è¨äºã§ã¯~/srcã¨ãã)
- ezaã³ãã³ãã®ç¢ºèª
brew install ghq fzf eza mkdir -p ~/src git config --global ghq.root '~/src' eza -l -g --icons
ezaã³ãã³ã確èªãããã¨ã¢ã¤ã³ã³ã?ã«ãªã£ã¦ããã®ã確èªã§ããã¨æãã¾ãã ãã®ã¢ã¤ã³ã³ã表示ããã«ã¯ãã¢ã¤ã³ã³ãå«ãã ãã©ã³ããã®ã¤ã³ã¹ãã¼ã«ãå¿ è¦ã«ãªãã¾ãã
ãã©ã³ãã¨ã¢ã¤ã³ã³è¨å®
https://github.com/ryanoasis/nerd-fonts
ã¢ã¤ã³ã³è¡¨ç¤ºã¨ãã©ã³ãã«ãæãããã®ã§ãã¿ããªå¤§å¥½ãNerdFontãã¤ã³ã¹ãã¼ã«ãããã¨æãã¾ãï¼ ãã®è¾ºãã¯åèªå¥½ããªãã®ãã使ç¨ãã ããã
brew install --cask font-jetbrains-mono-nerd-font
ã¿ã¼ããã«ä¸ã§ã®ãã©ã³ãè¨å®
[ã¿ã¼ããã«]â[è¨å®]â[ãã©ã³ã]ããJetBrainsMono Nerd Font Mono
ã¸å¤æ´
ãã©ã³ãè¨å®å®äºå¾ãã¿ã¼ããã«ãéãç´ãã¨ã¢ã¤ã³ã³ã表示ããã¾ãã
*ã¿ã¼ããã«(vscodeãiTerm2)ãã¨ã«è¡¨ç¤ºç¨ã®ãã©ã³ãè¨å®ãå¿
è¦ãªã®ã§æ³¨æãã¦ãã ããã
ããããã¯ãzshã®è¨å®
â ezaã®è¨å®
â åææ¡ä»¶
- ããã©ã«ãã·ã§ã«ã§zshã使ç¨ãã¦ãã
- ezaãã¤ã³ã¹ãã¼ã«ããã¦ãã
ezaãlsã®ä»£ç¨ã¨ãã¦ä½¿ç¨ããè¨å®
ããããã®è¨å®ã¯~/.zshrc
ã«è¿½è¨ãã¦ããã¾ãã
vscodeãã¤ã³ã¹ãã¼ã«æ¸ã¿ãªãcode ~/.zshrc
ã®ã³ãã³ãã§vscodeãç«ã¡ä¸ããç·¨éã§ãã¾ãã
# ã¨ã¤ãªã¢ã¹è¨å® # ezaãã¤ã³ã¹ãã¼ã«ããã¦ããå ´åã®ã¿æå¹å if [[ $(command -v eza) ]]; then alias e='eza --icons --git' alias l=e alias ls=e alias ea='eza -a --icons --git' alias la=ea alias ee='eza -aahl --icons --git' alias ll=ee alias et='eza -T -L 3 -a -I "node_modules|.git|.cache" --icons' alias lt=et alias eta='eza -T -a -I "node_modules|.git|.cache" --color=always --icons | less -r' alias lta=eta alias l='clear && ls' fi
â 以ä¸è§£èª¬ (ç°¡æ解説ã«ãªãã¾ã)
alias et='eza -T -L 3 -a -I "node_modules|.git|.cache" --icons' alias lt=et
alias eta='eza -T -a -I "node_modules|.git|.cache" --color=always --icons | less -r' alias lta=eta
ä¸è¨ï¼ã¤ã¯ãnode_modules
ã¨.git
ã¨.cache
ã®ãã©ã«ãã¼ãé¤ããçµæã表示ãã¦ããã¾ãã
â¡ghq fzf eza çµã¿åãã
â åææ¡ä»¶
- ããã©ã«ãã·ã§ã«ã§zshã使ç¨ãã¦ãã
- ghq fzf ezaãã¤ã³ã¹ãã¼ã«ããã¦ãã
control(^) + f
ã§ãã¼ã«ã«ãªãã¸ããªãé¸æã移åã§ããããã«ãé¢æ°ã¨ããããã¼ãã¤ã³ããããè¨å®ã~/.zshrc
ã«è¿½è¨
function ghq-fzf_change_directory() { # é¸æãããªãã¸ããªã¸ç§»å ã㤠# å³ã«ãªãã¸ããªã®ãã£ã¬ã¯ããªè©³ç´°ã表示 local src=$(ghq list | fzf --preview "eza -l -g -a --icons $(ghq root)/{} | tail -n+4 | awk '{print \$6\"/\"\$8\" \"\$9 \" \" \$10}'") if [ -n "$src" ]; then BUFFER="cd $(ghq root)/$src" zle accept-line fi zle -R -c } zle -N ghq-fzf_change_directory bindkey '^f' ghq-fzf_change_directory
â 以ä¸è§£èª¬
local src=$( ghq list | fzf --preview " eza -l -g -a --icons $(ghq root)/{} | tail -n+4 | awk '{print \$6\"/\"\$8\" \"\$9 \" \" \$10}'" )
ghqã³ãã³ã
ã使ã£ã¦ã管çãã¦ãããªãã¸ããªã®ãªã¹ããåå¾- fzfã®
--previewãªãã·ã§ã³
ã使ã£ã¦ãé¸æãããªãã¸ããªã®è©³ç´°ãå³å´ã«è¡¨ç¤ºezaã³ãã³ã
ã使ã£ã¦ãé¸æãããªãã¸ããªã®è©³ç´°ã表示tail -n+4
ã¯ãåºåã®æåã®3è¡ãã¹ãããããawk
ã§ãªãã¸ããªã®ãã¹ãæ å ±ãæ´å½¢
åå: eza -l -g -a --icons | tail -n+4 | awk '{print $6 "/" $8, $9, $10}'
ã·ã§ã«ã«åãè¾¼ãå ´åã¯ã¨ã¹ã±ã¼ããå®æ½
â ã©ããããµãã«æ
å ±ãæ´å½¢ããã¦ããã確èªãã¦ã¿ã¾ãããã
ä¾: ghq fzf ezaã®ãªãã¸ããªã§ç¢ºèªãã¾ãã
ghq get https://github.com/x-motemen/ghq https://github.com/junegunn/fzf https://github.com/eza-community/eza cd ~/src/github.com/eza-community/eza eza -l -g -a --icons eza -l -g -a --icons | tail -n+4 | awk '{print $6 "/" $8, $9, $10}'
è¨å®ãå
¨ã¦å®äºããã¨control(^)+f
ã§æ¤ç´¢ç»é¢âãéãã¾ãã
if [ -n "$src" ]; then BUFFER="cd $(ghq root)/$src" zle accept-line fi
ãã¡ãã¯ããªãã¸ããªãé¸æãããå ´åã«å®è¡ãããæ¡ä»¶æã§ã
BUFFERå¤æ°
ã¸é¸æãããªãã¸ããªã®ãã£ã¬ã¯ããªã«ç§»åããã³ãã³ããè¨å®- zshã®ã©ã¤ã³ã¨ãã£ã¿ï¼ZLEï¼ã«å¯¾ãã¦ãç¾å¨ã®ã³ãã³ããå®è¡ããããã«æ示
ããã«ãããcdã³ãã³ããå®è¡ãããé¸æãããªãã¸ããªã®ãã£ã¬ã¯ããªã«ç§»åã§ãã¾ãã
zle -R -c
æå¾ã«ãzshã®ã©ã¤ã³ã¨ãã£ã¿ããªãã¬ãã·ã¥
â åè ZLEã«ã¤ãã¦ã¯ã¯ã©ã¹ã¡ã½ããããã®è¨äºã大å¤åèã«ãªãã¾ãã
â¢cd + ls ã®è¨å® (cdã®å¾ã«lsããã)
åèï¼cdããå¾ã«lsããã®ã¯zshã«ããããã
ã«ã¬ã³ããã£ã¬ã¯ããªãå¤æ´ãããã¨ãã«çºç«ããchpwd
ã使ç¨
# hook cd+ls chpwd() { if [[ $(pwd) != $HOME ]]; then; ls fi }
â£ã¿ã¼ããã«èµ·åæã«ãã£ã¬ã¯ããªç§»åãããã
ã¿ã¼ããã«èµ·åæã«ãã£ã¬ã¯ããªç§»åã³ãã³ããå®è¡ããã
# zshèµ·åæã®å¦ç ## VSCodeã®ã¿ã¼ããã«ã使ã£ã¦ããªãããã¤ã ## ã¿ã¼ããã«ã§Homeãã£ã¬ã¯ããªå±éæã¯cdã³ãã³ããå®è¡ if [ "$TERM_PROGRAM" != "vscode" ] && [ "$PWD" = "$HOME" ] ; then cd ~/src fi ## eza(lsã®ä»£ãã)ã³ãã³ãã®å®è¡ if [[ $(command -v eza) ]]; then; eza --icons --git fi
ã¿ã¼ããã«æ
å ±ã¯ãecho $TERM_PROGRAM
ã§åå¾ã§ãã¾ãã
ã¿ã¼ããã«ã«ãã£ã¦ã¯ãã£ã¬ã¯ããªç§»åãæå¹åããããªãå ´åãããã®ã§ãããã§æ¡ä»¶ã追å ãã¦ã¿ã¦ãã ããã
æå¾ã«è¨å®ãåæ ããã¾ãããã ã¿ã¼ããã«ã®éãç´ããã以ä¸ã®ã³ãã³ãã§åæ ãã§ãã¾ãã
# èªã¿è¾¼ã¿(è¨å®åæ ) source ~/.zshrc
æå¾ã«
ããã ãã§ãããªã便å©ã§ãããããã«ããã³ãããã«ã¹ã¿ãã¤ãºããStarShipã¨ããtoolãããã¾ãã
é»æ± æ®éãã¡ã¢ãªã¼ä½¿ç¨éãªã©ããã¨ææ¡ããããã®ãããã³ããã«è¡¨ç¤ºã§ããããã«ãªãã¾ããä»å詳細ã¯å«ãã¾ãããæ¯é触ã£ã¦ã¿ã¦ãã ããã
brew install starship # æå¹ã«ãããã.zshrcã¸è¿½è¨ echo 'eval "$(starship init zsh)"' >> ~/.zshrc
ããã¾ã§ã®ããããã¡ã¤ã«ãç½®ãã¦ããã®ã§èªå好ã¿ã«è¨å®ãã¦ã¿ã¦ãã ããï¼
ã¾ãå¥æ¥ã«ãä¼ããã¾ãããï¼
# '~/.zshrc'ã«è¨è¼ # starshipèµ·åã«å¿ è¦ eval "$(starship init zsh)" # zshèµ·åæã®å¦ç ## VSCodeã®ã¿ã¼ããã«ã使ã£ã¦ããªãããã¤ã ## ã¿ã¼ããã«èµ·åæã«Homeãã£ã¬ã¯ããªã®å ´åã¯cdã³ãã³ããå®è¡ if [ "$TERM_PROGRAM" != "vscode" ] && [ "$PWD" = "$HOME" ] ; then cd ~/src fi ## eza(lsã®ä»£ãã)ã³ãã³ãã®å®è¡ if [[ $(command -v eza) ]]; then; eza --icons --git fi # hook # cd+ls chpwd() { if [[ $(pwd) != $HOME ]]; then; ls fi } # ã¨ã¤ãªã¢ã¹è¨å® # ezaãã¤ã³ã¹ãã¼ã«ããã¦ããå ´åã®ã¿æå¹å if [[ $(command -v eza) ]]; then alias e='eza --icons --git' alias l=e alias ls=e alias ea='eza -a --icons --git' alias la=ea alias ee='eza -aahl --icons --git' alias ll=ee alias et='eza -T -L 3 -a -I "node_modules|.git|.cache" --icons' alias lt=et alias eta='eza -T -a -I "node_modules|.git|.cache" --color=always --icons | less -r' alias lta=eta alias l='clear && ls' fi # func ## ghq fzf eza çµã¿åãã function ghq-fzf_change_directory() { # é¸æãããªãã¸ããªã¸ç§»å ã㤠# å³ã«ãªãã¸ããªã®ãã£ã¬ã¯ããªè©³ç´°ã表示 local src=$(ghq list | fzf --preview "eza -l -g -a --icons $(ghq root)/{} | tail -n+4 | awk '{print \$6\"/\"\$8\" \"\$9 \" \" \$10}'") if [ -n "$src" ]; then BUFFER="cd $(ghq root)/$src" zle accept-line fi zle -R -c } zle -N ghq-fzf_change_directory bindkey '^f' ghq-fzf_change_directory