MCPcopy Create free account
hub / github.com/diillson/chatcli / GetShellHistoryFile

Function GetShellHistoryFile

utils/shell_utils.go:56–77  ·  view source on GitHub ↗

GetShellHistoryFile retorna o caminho do arquivo de histórico do shell.

()

Source from the content-addressed store, hash-verified

54
55// GetShellHistoryFile retorna o caminho do arquivo de histórico do shell.
56func GetShellHistoryFile() (string, error) {
57 usr, err := userCurrent()
58 if err != nil {
59 return "", fmt.Errorf("não foi possível obter o usuário atual: %w", err)
60 }
61
62 shell := GetUserShell()
63 var historyFile string
64
65 switch shell {
66 case "bash":
67 historyFile = filepath.Join(usr.HomeDir, ".bash_history")
68 case "zsh":
69 historyFile = filepath.Join(usr.HomeDir, ".zsh_history")
70 case "fish":
71 historyFile = filepath.Join(usr.HomeDir, ".local", "share", "fish", "fish_history")
72 default:
73 return "", fmt.Errorf("shell não suportado ou não reconhecido: %s", shell)
74 }
75
76 return historyFile, nil
77}
78
79// GetShellHistory lê o arquivo de histórico do shell e retorna seu conteúdo.
80func GetShellHistory() (string, error) {

Callers 1

GetShellHistoryFunction · 0.85

Calls 2

GetUserShellFunction · 0.85
ErrorfMethod · 0.80

Tested by

no test coverage detected