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
220
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
69
Goとjsonで履歴書を管理できるようにしてみた / manage resumes with Go and json
usk81
3
850
データ分析の不都合な真実 / inconvenient truth on data analytics
usk81
0
590
とあるgopherが OpenCVをさわってみた話 / Introduction about OpenCV for gophers
usk81
0
230
Other Decks in Programming
See All in Programming
Zero Waste, Radical Magic, and Italian Graft – Quarkus Efficiency Secrets
hollycummins
0
210
From Spring Boot 2 to Spring Boot 3 with Java 21 and Jakarta EE
ivargrimstad
0
1.1k
甘い香りに誘われてVanilla Extractを1年間運用してみた
miyahkun
1
110
Git Lint
bkuhlmann
4
740
Folding Cheat Sheet #3
philipschwarz
PRO
0
110
ログラスを支える設計標準について / loglass-design-standards
urmot
10
2.1k
educure_カリキュラム生操作マニュアル.pdf
linew_official
0
450
元気予報
suu_mire0726
0
850
Micro Frontends for Java Microservices - Devnexus 2024
mraible
PRO
0
420
チーム力を高めるスクラム実践法:カンバン公開と課題攻略について - ニフティのスクラムトーク Vol. 2 - NIFTY Tech Talk #18
niftycorp
PRO
1
110
今、知っておきたい! 生成AIエージェントの世界
elith
3
340
コードレビューで学ぶ!Kotlinオブジェクト指向デザインパターン
akkie76
2
170
Featured
See All Featured
Building an army of robots
kneath
300
41k
Thoughts on Productivity
jonyablonski
57
3.8k
Build The Right Thing And Hit Your Dates
maggiecrowley
23
2k
A Tale of Four Properties
chriscoyier
150
22k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
Gamification - CAS2011
davidbonilla
76
4.6k
Fashionably flexible responsive web design (full day workshop)
malarkey
397
65k
What's new in Ruby 2.0
geeforr
337
31k
The Brand Is Dead. Long Live the Brand.
mthomps
48
28k
What's in a price? How to price your products and services
michaelherold
237
11k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.8k
We Have a Design System, Now What?
morganepeng
42
6.7k
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Ͱ ใࠂ͍ͤͯͩ͘͞͞