Skip to content

Commit

Permalink
CHORE: small cleanup, update README, setup example session_config.yam…
Browse files Browse the repository at this point in the history
…l file
  • Loading branch information
giuseppe-g-gelardi committed Nov 26, 2023
1 parent b211bee commit 75f9c8e
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 38 deletions.
53 changes: 38 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,57 @@

# git-sessionizer

### a little project to automate the creation of a sessionized git repo in your editor of choice, with tmux, or not...

the application uses github authentication and some interactive prompts to...
- init the application
- - authenticates with github via device flow
- lets you search through your public and private repositories
- select and clone a repo
- - clone with SSH or HTTP
- - - standard or bare (if you like worktrees) repository
- cd into directory
- start a tmux session, if that's your cup of tea
- and finally, open the repo in your preferred editor (vscode, vim, or neovim)
- - (soon) emacs and other stuff as well

TODO:

- init the application
- - authenticates with github via device flow
- lets you search through your public and private repositories
- select and clone a repo
- - clone with SSH or HTTP
- - - standard or bare (if you like worktrees) repository
- cd into directory
- start a tmux session, if that's your cup of tea
- and finally, open the repo in your preferred editor (vscode, vim, or neovim)
- - (soon) emacs and other stuff as well

TODO:

- [x] implement choice between standard or bare repo
- [ ] detect if tmux is active. if it is, attach and switch to the new window. otherwise create the new session as normal.
- [ ] additional editors
- [ ] bubbletea? bubbletea! (someone please help..... plz)

## To get started:

1. `git clone https://github.com/giuseppe-g-gelardi/git-sessionizer.git`
2. cd git-sessionizer
3. go mod tidy ...?
4. go run ./cmd
4. go run ./cmd/session

## Install

```sh
$ go install github.com/giuseppe-g-gelardi/git-sessionizer/cmd/session@latest
```

please keep in mind this is still VERY pre-alpha. id advise against installing unless you know what you're doing.

See [releases](https://github.com/giuseppe-g-gelardi/git-sessionizer/releases) for binaries

## config file location:

- windows:
- - APPDATA\local\session_config.yaml

- macos & linux:
- - /home/{user}/.config/session_config.yaml (~/.config/)

## contributing:

1. create a fork
2. create a branch
3. make a pr?
4. get mad at me when you realize i dont know how to merge it
4. get mad at me when you realize i dont know how to merge it -- kidding, mostly

but seriously, would be cool :D
37 changes: 18 additions & 19 deletions config/cfg_yml.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import (
"errors"
"fmt"
"os"
"os/user"
"path/filepath"
"runtime"
"time"
"os/user"
"path/filepath"
"runtime"

"gopkg.in/yaml.v3"
)
Expand All @@ -20,19 +19,18 @@ type Config struct {
}

type CfgManager struct {
ConfigFileName string
DefaultConfig Config
ConfigFileName string
DefaultConfig Config
}

/*
change the location of the config file.
- for linux and mac it is ~/.config/session_config.yaml
- for windows it is %APPDATA%\local\session_config.yaml ???
*/

func NewCfgManager() *CfgManager {
return &CfgManager{
ConfigFileName: getConfigFileLocation(), // ~/.config/session_config.yaml || %APPDATA%\local\session_config.yaml
ConfigFileName: getConfigFileLocation(), // ~/.config/session_config.yaml || %APPDATA%\local\session_config.yaml
DefaultConfig: Config{
AccessToken: "",
Editor: "vscode",
Expand Down Expand Up @@ -63,6 +61,7 @@ func getConfigFileLocation() string {
return ""
}

// still toying the with idea of creating a "git_sessionizer" directory
return filepath.Join(configDir, "session_config.yaml")
}

Expand Down Expand Up @@ -108,14 +107,14 @@ func (cm *CfgManager) WriteConfig(params interface{}) (*Config, error) {
return cm.GetConfig(0)
}

func (cm *CfgManager) RevalidateConfig() error {
time.AfterFunc(2*time.Second, func() {
updatedConfig, err := cm.GetConfig(0)
if err != nil || updatedConfig.AccessToken == "" {
// Unable to update or verify config
cm.GetConfig(0)
return
}
})
return nil
}
// func (cm *CfgManager) RevalidateConfig() error {
// time.AfterFunc(2*time.Second, func() {
// updatedConfig, err := cm.GetConfig(0)
// if err != nil || updatedConfig.AccessToken == "" {
// // Unable to update or verify config
// cm.GetConfig(0)
// return
// }
// })
// return nil
// }
4 changes: 4 additions & 0 deletions session_config.example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
access_token: "" # github access token for repo rights
editor: vscode # vscode | neovim | vim -- these are the current options
alias: "" # whatever you want!
tmux: false # ........
4 changes: 0 additions & 4 deletions session_config.yaml

This file was deleted.

0 comments on commit 75f9c8e

Please sign in to comment.