Skip to content

Commit c112c59

Browse files
authored
Merge pull request #42 from NucleoFusion/bug/40-41
bug: resolves 40 & 41
2 parents 6ecb2c6 + c193df4 commit c112c59

7 files changed

Lines changed: 38 additions & 26 deletions

File tree

cmd/init.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package cmd
22

33
import (
44
"fmt"
5-
"log"
65
"os"
76
"path/filepath"
87

@@ -15,7 +14,19 @@ var initCmd = &cobra.Command{
1514
Short: "Initialize Toney configuration",
1615
Run: func(cmd *cobra.Command, args []string) {
1716
if err := config.SetConfig(); err != nil {
18-
log.Fatalf("failed to load config: %v", err)
17+
home, _ := os.UserHomeDir()
18+
19+
err = os.MkdirAll(home+"/.config/toney", 0o755)
20+
if err != nil {
21+
fmt.Println("Could not create config directory", err.Error())
22+
return
23+
}
24+
25+
_, err = os.Create(home + "/.config/toney/config.toml")
26+
if err != nil {
27+
fmt.Println("Could not create config file", err.Error())
28+
return
29+
}
1930
}
2031

2132
fmt.Println("Initializing Toney...")
@@ -41,18 +52,6 @@ var initCmd = &cobra.Command{
4152
return
4253
}
4354

44-
err = os.MkdirAll(home+"/.config/toney", 0o755)
45-
if err != nil {
46-
fmt.Println("Could not create config directory", err.Error())
47-
return
48-
}
49-
50-
_, err = os.Create(home + "/.config/toney/config.toml")
51-
if err != nil {
52-
fmt.Println("Could not create config file", err.Error())
53-
return
54-
}
55-
5655
fmt.Println("Toney setup was succesfull!")
5756
},
5857
}

docs/docs/config/general.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ notes_dir = ".toney"
1313

1414
## Editor
1515

16-
can change the editor for editing notes using the `editor` key. **Make sure to write the command for the editor, not the name**.
16+
can change the editor for editing notes using the `editor` key, it takes an array. **Make sure to write the command for the editor, not the name**.
17+
18+
For users with _helix_, use `editor=["alacritty", "-e" , "bash", "-c", "hx"]` or change it according to your term and shell. Helix requires a TTY to launch hence this is required.
1719

1820
default value is:
1921
```toml
20-
editor = "nvim"
22+
editor = ["nvim"]
2123
```

docs/docs/guide/install.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
### Arch Linux (AUR)
1010

1111
```
12-
yay -S toney (TBD - not yet works)
12+
yay -S toney
1313
```
1414
> _maintained by [NucleoFusion](https://github.com/NucleoFusion)_
1515
1616
### Debian / Ubuntu (.deb)
1717

18-
Install the .deb file [_here_](https://www.youtube.com/watch?v=xvFZjo5PgG0&list=RDxvFZjo5PgG0&start_radio=1).
18+
Install the .deb file [_here_](https://github.com/SourcewareLab/Toney/releases/tag/v2.0.0).
1919

2020
```
2121
sudo apt install ./path/to/debfile
@@ -24,7 +24,7 @@ sudo apt install ./path/to/debfile
2424
2525
### Fedora / RHEL (.dnf)
2626

27-
Install the .dnf file [_here_](https://www.youtube.com/watch?v=xvFZjo5PgG0&list=RDxvFZjo5PgG0&start_radio=1).
27+
Install the .dnf file [_here_](https://github.com/SourcewareLab/Toney/releases/tag/v2.0.0).
2828

2929
```
3030
sudo dnf install ./path/to/debfile
@@ -33,9 +33,13 @@ sudo dnf install ./path/to/debfile
3333
3434
## Windows
3535

36-
Install the .exe file [_here_](https://www.youtube.com/watch?v=xvFZjo5PgG0&list=RDxvFZjo5PgG0&start_radio=1).
36+
Install the .zip file [_here_](https://github.com/SourcewareLab/Toney/releases/tag/v2.0.0).
37+
38+
39+
## MacOS
40+
41+
Install the .tar.gz file [_here_](https://github.com/SourcewareLab/Toney/releases/tag/v2.0.0).
3742

38-
Just run the exe and follow the installer instructions.
3943

4044
## From Source
4145

internal/config/configModels.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ type Config struct {
77
}
88

99
type GeneralConfig struct {
10-
Editor string `mapstructure:"editor"`
11-
NotesDir string `mapstructure:"notes_dir"`
10+
Editor []string `mapstructure:"editor"`
11+
NotesDir string `mapstructure:"notes_dir"`
1212
}

internal/config/default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import "github.com/charmbracelet/lipgloss"
55
func DefaultConfig() Config {
66
return Config{
77
General: GeneralConfig{
8-
Editor: "nvim",
8+
Editor: []string{"nvim"},
99
NotesDir: ".toney", // From $HOME Directory
1010
},
1111
Keybinds: KeybindsConfig{

internal/models/diary/diary.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ func (m *Diary) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
9292
switch {
9393
case key.Matches(msg, m.Keymap.Edit):
9494
home, _ := os.UserHomeDir()
95-
c := exec.Command(config.AppConfig.General.Editor, filepath.Join(home, m.DirPath, ".diary", m.CurrFileName))
95+
96+
args := config.AppConfig.General.Editor
97+
args = append(args, filepath.Join(home, m.DirPath, ".diary", m.CurrFileName))
98+
99+
c := exec.Command(args[0], args[1:]...)
96100
cmd := tea.ExecProcess(c, func(err error) tea.Msg {
97101
return messages.EditorClose{
98102
Err: err,

internal/models/fileExplorer/fileExplorer.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ func (m *FileExplorer) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
105105
return m, nil
106106
}
107107

108-
c := exec.Command(config.AppConfig.General.Editor, strings.TrimSuffix(filepopup.GetPath(m.CurrentNode), "/"))
108+
args := config.AppConfig.General.Editor
109+
args = append(args, strings.TrimSuffix(filepopup.GetPath(m.CurrentNode), "/"))
110+
111+
c := exec.Command(args[0], args[1:]...)
109112
cmd := tea.ExecProcess(c, func(err error) tea.Msg {
110113
return messages.EditorClose{
111114
Err: err,

0 commit comments

Comments
 (0)