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
Honoのおもしろいミドルウェアをみてみよう
yusukebe
1
200
『GO』アプリ バックエンドサーバのコスト削減
mot_techtalk
0
130
動作確認やテストで漏れがちな観点3選
starfish719
6
1k
Grafana Loki によるサーバログのコスト削減
mot_techtalk
1
110
Amazon Q Developer Proで効率化するAPI開発入門
seike460
PRO
0
110
Software Architecture
hschwentner
6
2.1k
sappoRo.R #12 初心者セッション
kosugitti
0
230
第3回関東Kaggler会_AtCoderはKaggleの役に立つ
chettub
3
890
ファインディの テックブログ爆誕までの軌跡
starfish719
2
1.1k
[Fin-JAWS 第38回 ~re:Invent 2024 金融re:Cap~]FaultInjectionServiceアップデート@pre:Invent2024
shintaro_fukatsu
0
400
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
XStateを用いた堅牢なReact Components設計~複雑なClient Stateをシンプルに~ @React Tokyo ミートアップ #2
kfurusho
1
770
Featured
See All Featured
Designing Experiences People Love
moore
139
23k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
400
BBQ
matthewcrist
86
9.5k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Being A Developer After 40
akosma
89
590k
Fireside Chat
paigeccino
34
3.2k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
29
4.6k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.8k
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Ͱ ใࠂ͍ͤͯͩ͘͞͞