Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package cmd

import (
"fmt"
"log"
"os"
"path/filepath"

Expand All @@ -15,7 +14,19 @@ var initCmd = &cobra.Command{
Short: "Initialize Toney configuration",
Run: func(cmd *cobra.Command, args []string) {
if err := config.SetConfig(); err != nil {
log.Fatalf("failed to load config: %v", err)
home, _ := os.UserHomeDir()

err = os.MkdirAll(home+"/.config/toney", 0o755)
if err != nil {
fmt.Println("Could not create config directory", err.Error())
return
}

_, err = os.Create(home + "/.config/toney/config.toml")
if err != nil {
fmt.Println("Could not create config file", err.Error())
return
}
}

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

err = os.MkdirAll(home+"/.config/toney", 0o755)
if err != nil {
fmt.Println("Could not create config directory", err.Error())
return
}

_, err = os.Create(home + "/.config/toney/config.toml")
if err != nil {
fmt.Println("Could not create config file", err.Error())
return
}

fmt.Println("Toney setup was succesfull!")
},
}
Expand Down
6 changes: 4 additions & 2 deletions docs/docs/config/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ notes_dir = ".toney"

## Editor

can change the editor for editing notes using the `editor` key. **Make sure to write the command for the editor, not the name**.
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**.

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.

default value is:
```toml
editor = "nvim"
editor = ["nvim"]
```
14 changes: 9 additions & 5 deletions docs/docs/guide/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
### Arch Linux (AUR)

```
yay -S toney (TBD - not yet works)
yay -S toney
```
> _maintained by [NucleoFusion](https://github.com/NucleoFusion)_

### Debian / Ubuntu (.deb)

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

```
sudo apt install ./path/to/debfile
Expand All @@ -24,7 +24,7 @@ sudo apt install ./path/to/debfile

### Fedora / RHEL (.dnf)

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

```
sudo dnf install ./path/to/debfile
Expand All @@ -33,9 +33,13 @@ sudo dnf install ./path/to/debfile

## Windows

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


## MacOS

Install the .tar.gz file [_here_](https://github.com/SourcewareLab/Toney/releases/tag/v2.0.0).

Just run the exe and follow the installer instructions.

## From Source

Expand Down
4 changes: 2 additions & 2 deletions internal/config/configModels.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ type Config struct {
}

type GeneralConfig struct {
Editor string `mapstructure:"editor"`
NotesDir string `mapstructure:"notes_dir"`
Editor []string `mapstructure:"editor"`
NotesDir string `mapstructure:"notes_dir"`
}
2 changes: 1 addition & 1 deletion internal/config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/charmbracelet/lipgloss"
func DefaultConfig() Config {
return Config{
General: GeneralConfig{
Editor: "nvim",
Editor: []string{"nvim"},
NotesDir: ".toney", // From $HOME Directory
},
Keybinds: KeybindsConfig{
Expand Down
6 changes: 5 additions & 1 deletion internal/models/diary/diary.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ func (m *Diary) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch {
case key.Matches(msg, m.Keymap.Edit):
home, _ := os.UserHomeDir()
c := exec.Command(config.AppConfig.General.Editor, filepath.Join(home, m.DirPath, ".diary", m.CurrFileName))

args := config.AppConfig.General.Editor
args = append(args, filepath.Join(home, m.DirPath, ".diary", m.CurrFileName))

c := exec.Command(args[0], args[1:]...)
cmd := tea.ExecProcess(c, func(err error) tea.Msg {
return messages.EditorClose{
Err: err,
Expand Down
5 changes: 4 additions & 1 deletion internal/models/fileExplorer/fileExplorer.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ func (m *FileExplorer) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
}

c := exec.Command(config.AppConfig.General.Editor, strings.TrimSuffix(filepopup.GetPath(m.CurrentNode), "/"))
args := config.AppConfig.General.Editor
args = append(args, strings.TrimSuffix(filepopup.GetPath(m.CurrentNode), "/"))

c := exec.Command(args[0], args[1:]...)
cmd := tea.ExecProcess(c, func(err error) tea.Msg {
return messages.EditorClose{
Err: err,
Expand Down