commit with package.sh

This commit is contained in:
bruno 2023-07-25 22:08:58 -04:00
parent 1d46a23824
commit 1d295276c4
10 changed files with 308 additions and 43 deletions

View File

@ -0,0 +1,50 @@
# Scut-Reminder
Scut-Reminder est un petit utilitaire en ligne de commande pour gérer et lister vos raccourcis d'application favoris.
## Usage
```
scut // Affiche la liste des applications
scut -c MaConfig.json -a "nevim" // Affiche liste des raccourcis de nevim de MaConfig.json
scut -a "Visual Studio Code" // Affiche liste des raccourcis de vscode
```
## Options
- `-c NomDuFichierConfig` Utiliser ce fichier de configuration au lieu de `config.json` (par défaut)
- `-a Nom Application` Afficher les raccourcis de l'application spécifiée
- `-h` Afficher l'aide
## Installation
Téléchargez le fichier binaire pour votre plateforme à partir de la section Releases.
Ou bien compilez le code source Go:
```
go build
```
## Configuration
Le fichier `config.json` doit respecter ce format :
```json
{
"apps": [
{
"name": "neovim",
"shortcuts": {
"ctrl+alt+n": "Open neovim",
"ctrl+n": "Split neovim horizontally"
}
},
{
"name": "vscode",
"shortcuts": {
"ctrl+shift+p": "Command palette"
}
}
]
}
```

View File

@ -1,23 +0,0 @@
{
"apps": [
{
"name": "neovim",
"shortcuts": {
"ctrl+alt+n": "Open neovim",
"ctrl+n": "Split neovim horizontally"
}
},
{
"name": "vscode",
"shortcuts": {
"ctrl+shift+p": "Command palette"
}
},
{
"name": "Kitty",
"shortcuts": {
"ctrl+shift+e": "Open new terminal"
}
}
]
}

41
configuration/gnome.json Normal file
View File

@ -0,0 +1,41 @@
{
"name": "GNOME",
"shortcuts": {
"ctrl+alt+t": "Terminal",
"ctrl+alt+d": "Show Desktop",
"super": "Activities Overview",
"super+a": "Applications",
"super+f": "Files",
"super+t": "Terminal",
"super+l": "Lock Screen",
"super+shift+q": "Log Out",
"super+shift+d": "Show Applications",
"super+page up": "Switch Workspace on the right",
"super+page down": "Switch Workspace on the left",
"super+1-9": "Switch to Workspace 1-9",
"ctrl+alt+arrow": "Switch Workspace",
"ctrl+alt+up": "Maximize Window",
"ctrl+alt+down": "Unmaximize Window",
"alt+tab": "Switch Applications",
"alt+`": "Switch Windows of the Same Application",
"alt+f2": "Run Command",
"ctrl+alt+delete": "Log Out/Power Off/Restart",
"ctrl+c": "Copy",
"ctrl+v": "Paste",
"ctrl+x": "Cut",
"ctrl+z": "Undo",
"ctrl+shift+z": "Redo",
"ctrl+a": "Select All",
"ctrl+f": "Find",
"ctrl+s": "Save",
"ctrl+o": "Open",
"ctrl+n": "New",
"ctrl+p": "Print",
"ctrl+q": "Quit",
"ctrl+w": "Close Window",
"ctrl+shift+w": "Close All Windows",
"ctrl+shift+t": "Reopen Closed Tab/Window",
"ctrl+plus": "Zoom In",
"ctrl+minus": "Zoom Out"
}
}

40
configuration/kitty.json Normal file
View File

@ -0,0 +1,40 @@
{
"name": "Kitty Terminal",
"shortcuts": {
"Ctrl+Shift+T": "New tab",
"Ctrl+Shift+W": "Close tab",
"Ctrl+Shift+H": "Move focus to left tab",
"Ctrl+Shift+L": "Move focus to right tab",
"Ctrl+Shift+PageUp": "Move to previous tab",
"Ctrl+Shift+PageDown": "Move to next tab",
"Ctrl+Shift+C": "Copy selected text to clipboard",
"Ctrl+Shift+V": "Paste from clipboard",
"Ctrl+Shift+N": "New Kitty instance",
"Ctrl+Shift+Q": "Quit Kitty",
"Ctrl+Shift+R": "Reload configuration file",
"Ctrl+Shift+F": "Find",
"Ctrl+Shift+G": "Find next",
"Ctrl+Shift+J": "Scroll down one line",
"Ctrl+Shift+K": "Scroll up one line",
"Ctrl+Shift+U": "Scroll up one page",
"Ctrl+Shift+D": "Scroll down one page",
"Ctrl+Shift+Home": "Scroll to top",
"Ctrl+Shift+End": "Scroll to bottom",
"Ctrl+Shift+S": "Save session",
"Ctrl+Shift+O": "Open saved session",
"Ctrl+Shift+X": "Clear scrollback buffer",
"Ctrl+Shift+Z": "Toggle zoom",
"Ctrl+Shift+I": "Inspect current terminal",
"Ctrl+Shift+Tab": "Switch to previous window",
"Ctrl+Shift+Num+": "Increase font size",
"Ctrl+Shift+Num-": "Decrease font size",
"Ctrl+Shift+Num*": "Reset font size",
"Ctrl+Shift+Num/": "Toggle ligatures",
"Ctrl+Shift+Num0": "Reset all settings to default",
"Ctrl+Shift+Num1": "Switch to profile 1",
"Ctrl+Shift+Num2": "Switch to profile 2",
"Ctrl+Shift+Num3": "Switch to profile 3",
"Ctrl+Shift+Num4": "Switch to profile 4",
"Ctrl+Shift+Num5": "Switch to profile 5"
}
}

39
configuration/neovim.json Normal file
View File

@ -0,0 +1,39 @@
{
"name": "Neovim",
"shortcuts": {
"i": "Insert mode",
"esc": "Normal mode",
"gg": "Go to first line",
"G": "Go to last line",
"dd": "Delete current line",
"yy": "Yank/copy current line",
"p": "Paste yanked/cut text",
"u": "Undo",
"Ctrl-r": "Redo",
"w": "Save changes",
"q": "Quit",
"Ctrl-w": "Close current window",
"Ctrl-n": "Open new empty buffer",
"Ctrl-o": "Open last closed buffer",
"Ctrl-^": "Switch between the current and previous buffer",
"Ctrl-]": "Jump to the definition of a symbol",
"Ctrl-t": "Jump back from the definition of a symbol",
"Ctrl-p": "Open fuzzy finder",
"Ctrl-x Ctrl-f": "Open file explorer",
"Ctrl-x Ctrl-b": "Open buffer explorer",
"Ctrl-g": "Show file information",
"Ctrl-a": "Select all",
"Ctrl-v": "Paste in visual mode",
"v": "Enter visual mode",
"V": "Enter line visual mode",
"Ctrl-c": "Copy in visual mode",
"y": "Yank in visual mode",
"d": "Delete in visual mode",
"c": "Change in visual mode",
"r": "Replace in visual mode",
"s": "Substitute in visual mode",
"Ctrl-l": "Clear search highlight",
"n": "Next search result",
"N": "Previous search result"
}
}

41
configuration/vscode.json Normal file
View File

@ -0,0 +1,41 @@
{
"name": "Visual Studio Code",
"shortcuts": {
"Ctrl+Shift+P": "Command Palette",
"Ctrl+Shift+N": "New Window",
"Ctrl+Shift+W": "Close Window",
"Ctrl+Shift+T": "Reopen Closed Editor",
"Ctrl+Tab": "Switch Editor",
"Ctrl+Shift+Tab": "Switch Editor in Reverse Order",
"Ctrl+Shift+M": "Toggle Problems Panel",
"Ctrl+Shift+G": "Toggle Source Control",
"Ctrl+Shift+D": "Toggle Debug",
"Ctrl+Shift+X": "Toggle Extensions",
"Ctrl+Shift+V": "Open Markdown Preview",
"Ctrl+K V": "Open Markdown Preview to the Side",
"Ctrl+Shift+F": "Find in Files",
"Ctrl+F": "Find",
"Ctrl+H": "Replace",
"F12": "Go to Definition",
"Ctrl+F12": "Go to Definition (in the same file)",
"Alt+F12": "Peek Definition",
"Ctrl+Shift+O": "Go to Symbol",
"Ctrl+Shift+M": "Show Problems",
"Ctrl+Shift+J": "Toggle Search Details",
"Ctrl+Shift+D": "Duplicate Line or Selection",
"Alt+Up": "Move Line Up",
"Alt+Down": "Move Line Down",
"Ctrl+Shift+K": "Delete Line",
"Ctrl+D": "Add Selection to Next Find Match",
"Ctrl+K Ctrl+D": "Move Last Selection to Next Find Match",
"Alt+Left": "Go Back",
"Alt+Right": "Go Forward",
"Ctrl+Shift+U": "Change Case",
"Ctrl+K Z": "Toggle Zen Mode",
"Ctrl+K S": "Toggle Editor Group Layout",
"Ctrl+K Ctrl+W": "Close All Editors",
"Ctrl+Shift+E": "Show Explorer",
"Ctrl+Shift+H": "Replace in Workspace",
"Ctrl+K Ctrl+X": "Trim Trailing Whitespace"
}
}

10
package.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
# Build le script scut.go
go build scut.go
# Créer l'archive zip
zip -r scut.zip scut README.md configuration
# Renommer l'archive
mv scut.zip scut-$(date +%Y%m%d).zip

BIN
scut

Binary file not shown.

BIN
scut-20230725.zip Normal file

Binary file not shown.

107
scut.go
View File

@ -5,6 +5,11 @@ import (
"flag" "flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os"
"path/filepath"
"strings"
"text/tabwriter"
"unicode"
) )
type App struct { type App struct {
@ -16,46 +21,108 @@ type Config struct {
Apps []App `json:"apps"` Apps []App `json:"apps"`
} }
func loadConfig(dir string) Config {
apps := []App{}
// Ouvre le répertoire config
files, err := ioutil.ReadDir(dir)
if err != nil {
//panic(err)
fmt.Println("Le répertoire config est inexistant !")
os.Exit(1)
}
// Lis tous les fichiers .json
for _, file := range files {
if filepath.Ext(file.Name()) == ".json" {
data, _ := ioutil.ReadFile(dir + "/" + file.Name())
var app App
json.Unmarshal(data, &app)
apps = append(apps, app)
}
}
config := Config{
Apps: apps,
}
return config
}
func main() { func main() {
underline := "- -- - -- - -- - -- - -- - -- - -- - -- - -- - --"
flag.Usage = func() { flag.Usage = func() {
fmt.Println("") fmt.Println("")
fmt.Println("- -- - -- - -- - -- - -- - -- - -- - --") fmt.Println(underline)
fmt.Println("Scut-Reminder : Gestion des raccourcis") fmt.Println(" Scut-Reminder : Gestion des raccourcis")
fmt.Println("- -- - -- - -- - -- - -- - -- - -- - --") fmt.Println(underline)
fmt.Println("Options :") fmt.Println("\n Options :")
fmt.Printf(" -c NomDuFichierConfig Utiliser ce fichier de configuration au lieu de config.json (par défaut)\n") fmt.Println(underline)
fmt.Printf(" -a Nom Application Afficher les raccourcis de l'application spécifiée\n") fmt.Printf(" -c PathDuDossierConfig || Path du dossier de configuration au lieu du répertoire ./config (par défaut)\n")
fmt.Printf(" -h Afficher cette aide\n") fmt.Printf(" -a Nom Application || Afficher les raccourcis de l'application spécifiée\n")
fmt.Printf(" -f fitre || Filtrer les raccourcis qui contiennent le filtre\n")
fmt.Printf(" -h || Afficher cette aide\n")
fmt.Println("") fmt.Println("")
fmt.Println("Example :") fmt.Println(" Example :")
fmt.Printf(" scut // Affiche la liste des applications\n\n") fmt.Println(underline)
fmt.Printf(" scut -c MaConfig.json -a \"nevim\" // Affiche liste des raccourcis de nevim de MaConfig.json \n\n") fmt.Printf(" scut || Affiche la liste des applications\n\n")
fmt.Printf(" scut -a \"Visual Studio Code\" //Affiche liste des raccourcis de vscode \n\n") fmt.Printf(" scut -c MaConfig.json -a \"nevim\" || Affiche liste des raccourcis de nevim de MaConfig.json \n\n")
fmt.Printf(" scut -a \"Visual Studio Code\" || Affiche liste des raccourcis de vscode \n\n")
fmt.Printf(" scut -a \"Kitty\" -f quit || Affiche liste des raccourcis qui contient 'quit' \n\n")
fmt.Println("") fmt.Println("")
} }
configFile := flag.String("c", "config.json", "Config file") configDir := flag.String("c", "config", "Config directory")
appName := flag.String("a", "", "Application name") appName := flag.String("a", "", "Application name")
filter := flag.String("f", "", "Filter")
flag.Parse() flag.Parse()
data, _ := ioutil.ReadFile(*configFile) config := loadConfig(*configDir)
var config Config
json.Unmarshal(data, &config) cleanFilter := strings.TrimFunc(*filter, func(r rune) bool {
return !unicode.IsGraphic(r)
})
if *appName == "" { if *appName == "" {
// List all applications // List all applications
fmt.Println(underline)
fmt.Println(" A P P L I C A T I O N S")
fmt.Println(underline)
for _, app := range config.Apps { for _, app := range config.Apps {
fmt.Printf("%s\n", app.Name) fmt.Printf("%s\n", app.Name)
} }
fmt.Println()
} else { } else {
// List shortcuts for application w := tabwriter.NewWriter(os.Stdout, 0, 0, 10, '.', 0)
for _, app := range config.Apps { if *filter != "" {
if app.Name == *appName { for _, app := range config.Apps {
for shortcut, desc := range app.Shortcuts { if strings.ToUpper(app.Name) == strings.ToUpper(*appName) {
fmt.Printf("%s: %s\n", shortcut, desc) fmt.Println(underline)
fmt.Fprintln(w, " S H O R T C U T S : "+app.Name)
fmt.Println(underline)
for shortcut, desc := range app.Shortcuts {
if strings.Contains(strings.ToUpper(shortcut), strings.ToUpper(cleanFilter)) || strings.Contains(strings.ToUpper(desc), strings.ToUpper(cleanFilter)) {
fmt.Fprintf(w, "%s \t %s\n", shortcut, desc)
}
}
} }
} }
w.Flush()
} else {
for _, app := range config.Apps {
if strings.ToUpper(app.Name) == strings.ToUpper(*appName) {
fmt.Println(underline)
fmt.Fprintln(w, " S H O R T C U T S : "+app.Name)
fmt.Println(underline)
for shortcut, desc := range app.Shortcuts {
fmt.Fprintf(w, "%s \t %s\n", shortcut, desc)
}
}
}
w.Flush()
} }
} }
} }