mirror of
https://github.com/ddworken/hishtory.git
synced 2024-12-26 16:58:55 +01:00
parent
06f52ac8aa
commit
eb72786e3a
@ -3424,4 +3424,15 @@ func TestExistingBashProfileDoesNotSourceProfile(t *testing.T) {
|
||||
require.Contains(t, string(bashProfileContent), "# Hishtory Config:\n")
|
||||
}
|
||||
|
||||
func TestStatusFullConfig(t *testing.T) {
|
||||
markTestForSharding(t, 19)
|
||||
defer testutils.BackupAndRestore(t)()
|
||||
tester := zshTester{}
|
||||
installHishtory(t, tester, "")
|
||||
|
||||
// Check default log level
|
||||
out := tester.RunInteractiveShell(t, `hishtory status --full-config | grep -v 'Secret Key'`)
|
||||
testutils.CompareGoldens(t, out, "TestStatusFullConfig")
|
||||
}
|
||||
|
||||
// TODO: somehow test/confirm that hishtory works even if only bash/only zsh is installed
|
||||
|
@ -2,15 +2,20 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/ddworken/hishtory/client/data"
|
||||
"github.com/ddworken/hishtory/client/hctx"
|
||||
"github.com/ddworken/hishtory/client/lib"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
var verbose *bool
|
||||
var (
|
||||
verbose *bool
|
||||
configFlag *bool
|
||||
)
|
||||
|
||||
var statusCmd = &cobra.Command{
|
||||
Use: "status",
|
||||
@ -26,6 +31,14 @@ var statusCmd = &cobra.Command{
|
||||
printOnlineStatus(config)
|
||||
}
|
||||
fmt.Printf("Commit Hash: %s\n", lib.GitCommit)
|
||||
if *configFlag {
|
||||
y, err := yaml.Marshal(config)
|
||||
if err != nil {
|
||||
lib.CheckFatalError(fmt.Errorf("failed to marshal config to yaml: %w", err))
|
||||
}
|
||||
indented := "\t" + strings.ReplaceAll(string(y), "\n", "\n\t")
|
||||
fmt.Printf("Full Config:\n%s\n", indented)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@ -49,4 +62,5 @@ func printOnlineStatus(config *hctx.ClientConfig) {
|
||||
func init() {
|
||||
rootCmd.AddCommand(statusCmd)
|
||||
verbose = statusCmd.Flags().BoolP("verbose", "v", false, "Display verbose hiSHtory information")
|
||||
configFlag = statusCmd.Flags().Bool("full-config", false, "Display hiSHtory's full config")
|
||||
}
|
||||
|
@ -170,24 +170,24 @@ func GetHome(ctx context.Context) string {
|
||||
|
||||
type ClientConfig struct {
|
||||
// The user secret that is used to derive encryption keys for syncing history entries
|
||||
UserSecret string `json:"user_secret"`
|
||||
UserSecret string `json:"user_secret" yaml:"-"`
|
||||
// Whether hishtory recording is enabled
|
||||
IsEnabled bool `json:"is_enabled"`
|
||||
IsEnabled bool `json:"is_enabled" yaml:"-"`
|
||||
// A device ID used to track which history entry came from which device for remote syncing
|
||||
DeviceId string `json:"device_id"`
|
||||
DeviceId string `json:"device_id" yaml:"-"`
|
||||
// Used for skipping history entries prefixed with a space in bash
|
||||
LastPreSavedHistoryLine string `json:"last_presaved_history_line"`
|
||||
LastPreSavedHistoryLine string `json:"last_presaved_history_line" yaml:"-"`
|
||||
// Used for skipping history entries prefixed with a space in bash
|
||||
LastSavedHistoryLine string `json:"last_saved_history_line"`
|
||||
LastSavedHistoryLine string `json:"last_saved_history_line" yaml:"-"`
|
||||
// Used for uploading history entries that we failed to upload due to a missing network connection
|
||||
HaveMissedUploads bool `json:"have_missed_uploads"`
|
||||
MissedUploadTimestamp int64 `json:"missed_upload_timestamp"`
|
||||
HaveMissedUploads bool `json:"have_missed_uploads" yaml:"-"`
|
||||
MissedUploadTimestamp int64 `json:"missed_upload_timestamp" yaml:"-"`
|
||||
// Used for uploading deletion requests that we failed to upload due to a missed network connection
|
||||
// Note that this is only applicable for deleting pre-saved entries. For interactive deletion, we just
|
||||
// show the user an error message if they're offline.
|
||||
PendingDeletionRequests []shared.DeletionRequest `json:"pending_deletion_requests"`
|
||||
PendingDeletionRequests []shared.DeletionRequest `json:"pending_deletion_requests" yaml:"-"`
|
||||
// Used for avoiding double imports of .bash_history
|
||||
HaveCompletedInitialImport bool `json:"have_completed_initial_import"`
|
||||
HaveCompletedInitialImport bool `json:"have_completed_initial_import" yaml:"-"`
|
||||
// Whether control-r bindings are enabled
|
||||
ControlRSearchEnabled bool `json:"enable_control_r_search"`
|
||||
// The set of columns that the user wants to be displayed
|
||||
|
71
client/testdata/TestStatusFullConfig
vendored
Normal file
71
client/testdata/TestStatusFullConfig
vendored
Normal file
@ -0,0 +1,71 @@
|
||||
hiSHtory: v0.Unknown
|
||||
Enabled: true
|
||||
Commit Hash: Unknown
|
||||
Full Config:
|
||||
controlrsearchenabled: true
|
||||
displayedcolumns:
|
||||
- Hostname
|
||||
- CWD
|
||||
- Timestamp
|
||||
- Runtime
|
||||
- Exit Code
|
||||
- Command
|
||||
customcolumns: []
|
||||
forcecompactmode: false
|
||||
isoffline: false
|
||||
filterduplicatecommands: false
|
||||
timestampformat: Jan 2 2006 15:04:05 MST
|
||||
betamode: false
|
||||
highlightmatches: true
|
||||
aicompletion: true
|
||||
enablepresaving: true
|
||||
colorscheme:
|
||||
selectedtext: '#ffff99'
|
||||
selectedbackground: '#3300ff'
|
||||
bordercolor: '#585858'
|
||||
defaultfilter: ""
|
||||
aicompletionendpoint: https://api.openai.com/v1/chat/completions
|
||||
keybindings:
|
||||
up:
|
||||
- up
|
||||
- alt+OA
|
||||
- ctrl+p
|
||||
down:
|
||||
- down
|
||||
- alt+OB
|
||||
- ctrl+n
|
||||
pageup:
|
||||
- pgup
|
||||
pagedown:
|
||||
- pgdown
|
||||
selectentry:
|
||||
- enter
|
||||
selectentryandchangedir:
|
||||
- ctrl+x
|
||||
left:
|
||||
- left
|
||||
right:
|
||||
- right
|
||||
tableleft:
|
||||
- shift+left
|
||||
tableright:
|
||||
- shift+right
|
||||
deleteentry:
|
||||
- ctrl+k
|
||||
help:
|
||||
- ctrl+h
|
||||
quit:
|
||||
- esc
|
||||
- ctrl+c
|
||||
- ctrl+d
|
||||
jumpstartofinput:
|
||||
- ctrl+a
|
||||
jumpendofinput:
|
||||
- ctrl+e
|
||||
wordleft:
|
||||
- ctrl+left
|
||||
wordright:
|
||||
- ctrl+right
|
||||
loglevel: info
|
||||
fullscreenrendering: false
|
||||
|
Loading…
Reference in New Issue
Block a user