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
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
540
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
310
カスタムしながら理解するGraphQL Connection
yanagii
1
1.5k
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
17
4.3k
Kaigi on Rails 2024 - Rails APIモードのためのシンプルで効果的なCSRF対策 / kaigionrails-2024-csrf
corocn
5
3.7k
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
100
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.3k
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
590
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
180
Jakarta EE meets AI
ivargrimstad
0
160
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
270
Tauriでネイティブアプリを作りたい
tsucchinoko
0
350
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
It's Worth the Effort
3n
183
27k
The Pragmatic Product Professional
lauravandoore
31
6.3k
How GitHub (no longer) Works
holman
310
140k
Side Projects
sachag
452
42k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Navigating Team Friction
lara
183
14k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
42
2.2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
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Ͱ ใࠂ͍ͤͯͩ͘͞͞