Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Create shell manager with golang
Search
Yusuke Komatsu
November 05, 2019
Programming
0
250
Create shell manager with golang
slide for golang.tokyo#27
Yusuke Komatsu
November 05, 2019
Tweet
Share
More Decks by Yusuke Komatsu
See All by Yusuke Komatsu
そろそろ Privacy の話をしないか? / Let's talk about privacy!!
usk81
0
76
Goとjsonで履歴書を管理できるようにしてみた / manage resumes with Go and json
usk81
3
940
データ分析の不都合な真実 / inconvenient truth on data analytics
usk81
0
600
とあるgopherが OpenCVをさわってみた話 / Introduction about OpenCV for gophers
usk81
0
270
Other Decks in Programming
See All in Programming
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
170
テストをしないQAエンジニアは何をしているか?
nealle
0
130
DevinとCursorから学ぶAIエージェントメモリーの設計とMoatの考え方
itarutomy
1
640
法律の脱レガシーに学ぶフロントエンド刷新
oguemon
5
730
AHC041解説
terryu16
0
590
富山発の個人開発サービスで日本中の学校の業務を改善した話
krpk1900
4
370
TokyoR116_BeginnersSession1_環境構築
kotatyamtema
0
110
一休.com のログイン体験を支える技術 〜Web Components x Vue.js 活用事例と最適化について〜
atsumim
0
110
Bedrock Agentsレスポンス解析によるAgentのOps
licux
2
720
Kanzawa.rbのLT大会を支える技術の裏側を変更する Ruby on Rails + Litestream 編
muryoimpl
0
220
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
170
Software Architecture
hschwentner
6
2.1k
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
193
16k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Visualization
eitanlees
146
15k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
29
1k
Optimizing for Happiness
mojombo
376
70k
Writing Fast Ruby
sferik
628
61k
Documentation Writing (for coders)
carmenintech
67
4.6k
Facilitating Awesome Meetings
lara
51
6.2k
The World Runs on Bad Software
bkeepers
PRO
67
11k
Transcript
Create shell manager with golang Photo by Ilya Pavlov on
Unsplash Yusuke Komatsu GitHub: usk81
Create shell manager with golang Photo by Ilya Pavlov on
Unsplash Yusuke Komatsu GitHub: usk81 creating
{ "basics": { "name": "Yusuke Komatsu" }, "skills": [ {"name":
"Data Analyst"}, {"name": "Web Development"} ], "works": [ {"company": "Persol Process & Technology"}, ], "interests": [ {"name": "Fortnite"}, {"name": "Coffee"}, {"name": "Machine Learning"} ] } About Me:
None
None
Create shell manager with golang Photo by Ilya Pavlov on
Unsplash creating
https://github.com/getshway/shway
Origin of name (public stance) sh(ell) + way = shway
Origin of name SCHWAY!! DC Comic The flash
Motivation
Motivation Change default shell to zsh
Motivation
Motivation How to manage dotfiles?
Motivation
Motivation
Motivation Can I use Homebrew on future Mac?
Motivation
Motivation
Motivation How to share development environment?
Motivation Join a new project
Motivation Join a new project Get ready in 40 seconds!
Motivation development environment ↓ as shell scripts ↓ manage with
git ↓ get from git repos ↓ we can share!!
What’s SHWAY !?
What’s SHWAY !? milestone • manage dot files • manage
homebrew and cask • manage ssh config • install homebrew and dependency packages when initialize shway
What’s SHWAY !? current features •manage your •dot files •homebrew
and cask •manage your team •dot files •homebrew and cask
What’s SHWAY !? # initialize shway $ shway init #
sets a project (dotfiles) from github $ shway set foobar
[email protected]
:getshway/sampleproject.git … # update a project and update/install homebrew and homebrew-cask $ shway update foobar Updated 5 taps (golangci/tap, homebrew/cask-versions, homebrew/core, homebrew/cask and homebrew/cask-fonts). ==> New Formulae awsume dvc govc grin grin-wallet javacc minikube navi nbdime ngt onefetch pnpm prestosql pylint tdkjs toast ttyplot wal2json ==> Updated Formulae ack ✔ borgmatic docfx gleam libphonenumber osquery s3ql terragrunt awscli ✔ botan docker glooctl librsvg paket salt terrahub dark-mode ✔ buku docker-completion gnuradio librsync pango saxon theharvester ...
I thought I could create 2 days But I couldn’t
I couldn’t create 2days Change specification 1. Coding shell script
shell script -> Golang Maybe, can not maintenance 2. source command is not work with Go 3. stdout is caught source command
source command is not work with Go // golang //
not work exec.Command("source", “something.sh").Run() // not work exec.Command("bash", "-c", "source", "something.sh").Run() 1SPDFTT TIXBZ 1SPDFTT TIFMM TPVSDF 1SPDFTT UFSNJOBM UBSHFUDVSSFOUQSPDFTT
source command is not work with Go $ shway init
shway() { case "$1" in init | load) source <( /usr/local/bin/shway $@ ) || /usr/local/bin/shway $@ ;; set | update) /usr/local/bin/shway $@ && source <( /usr/local/bin/shway load $2 ) || /usr/local/bin/shway $@ ;; *) /usr/local/bin/shway $@ ;; esac } _shway() { IFS=' ' read -A reply <<< "help set update load list init" } compctl -K _shway shway source /Users/usk/.shway/default/.alias source /Users/usk/.shway/default/.completions source /Users/usk/.shway/default/.functions source /Users/usk/.shway/default/.golang source /Users/usk/.shway/default/.history #.zshrc source <(shway init)
refer. antibody $ antibody init #!/usr/bin/env zsh antibody() { case
"$1" in bundle) source <( /usr/local/bin/antibody $@ ) || /usr/local/bin/antibody $@ ;; *) /usr/local/bin/antibody $@ ;; esac } _antibody() { IFS=' ' read -A reply <<< "help bundle update home purge list init" } compctl -K _antibody antibody #.zshrc source <(antibody init) https://getantibody.github.io/
stdout is caught source command $ shway init shway() {
case "$1" in init | load) source <( /usr/local/bin/shway $@ ) || /usr/local/bin/shway $@ ;; set | update) /usr/local/bin/shway $@ && source <( /usr/local/bin/shway load $2 ) || /usr/local/bin/ shway $@ ;; *) /usr/local/bin/shway $@ ;; esac } _shway() { IFS=' ' read -A reply <<< "help set update load list init" } compctl -K _shway shway source /Users/usk/.shway/default/.alias source /Users/usk/.shway/default/.completions source /Users/usk/.shway/default/.functions source /Users/usk/.shway/default/.golang source /Users/usk/.shway/default/.history update dot files and brews and install brews source dot files
stdout is caught source command // Exit finishs requests func
Exit(err error, codes ...int) { log.SetOutput(os.Stderr) log.SetPrefix("shway: ") log.SetFlags(0) var code int if len(codes) > 0 { code = codes[0] } else { code = 1 } log.Print(err.Error()) os.Exit(code) }
Awesome packages https://github.com/src-d/go-git
Awesome packages https://github.com/src-d/go-git
Awesome packages https://github.com/spf13/cobra
Awesome packages package command import ( "fmt" "github.com/getshway/shway/initialize" "github.com/spf13/cobra" )
var ( initCmd = &cobra.Command{ Use: "init", Short: "setup shway and load zsh config", Long: "setup shway and load zsh config", Run: initCommand, } ) func init() { RootCmd.AddCommand(initCmd) } func initCommand(cmd *cobra.Command, args []string) { out, err := initialize.Run() if err != nil { Exit(err, 1) } fmt.Println(out) } define as a use case command package
Thank you ϦϦʔεͰ͖ͨΒ Ͳ͔ͬͷLTͰ ใࠂ͍ͤͯͩ͘͞͞