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
240
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
72
Goとjsonで履歴書を管理できるようにしてみた / manage resumes with Go and json
usk81
3
910
データ分析の不都合な真実 / inconvenient truth on data analytics
usk81
0
590
とあるgopherが OpenCVをさわってみた話 / Introduction about OpenCV for gophers
usk81
0
250
Other Decks in Programming
See All in Programming
Missing parts when designing and implementing Android UI
ericksli
0
310
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2.1k
大規模サイトリビルドの現場から:成功と失敗のリアルな教訓 / Site Rebuild,Real Lessons Learned from Successes and Failures_JJUG Fall 2024
techtekt
0
120
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
5
3.3k
DevTools extensions で 独自の DevTool を開発する | FlutterKaigi 2024
kokiyoshida
0
160
subpath importsで始めるモック生活
10tera
0
350
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
15
2.3k
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
3
770
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
2.2k
CSC509 Lecture 12
javiergs
PRO
0
160
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
150
Remix on Hono on Cloudflare Workers
yusukebe
1
330
Featured
See All Featured
Designing the Hi-DPI Web
ddemaree
280
34k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Documentation Writing (for coders)
carmenintech
65
4.4k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Code Reviewing Like a Champion
maltzj
520
39k
Thoughts on Productivity
jonyablonski
67
4.3k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
730
Typedesign – Prime Four
hannesfritz
40
2.4k
Building Applications with DynamoDB
mza
90
6.1k
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Ͱ ใࠂ͍ͤͯͩ͘͞͞