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

Function GetShellHistory

utils/shell_utils.go:80–102  ·  view source on GitHub ↗

GetShellHistory lê o arquivo de histórico do shell e retorna seu conteúdo.

()

Source from the content-addressed store, hash-verified

78
79// GetShellHistory lê o arquivo de histórico do shell e retorna seu conteúdo.
80func GetShellHistory() (string, error) {
81 historyFile, err := GetShellHistoryFile()
82 if err != nil {
83 return "", err
84 }
85
86 if _, err := osStat(historyFile); os.IsNotExist(err) {
87 return "", fmt.Errorf("arquivo de histórico não encontrado: %s", historyFile)
88 }
89
90 data, err := osReadFile(historyFile)
91 if err != nil {
92 return "", fmt.Errorf("erro ao ler o arquivo de histórico: %w", err)
93 }
94
95 shell := GetUserShell()
96 if shell == "zsh" {
97 processedData := processZshHistory(string(data))
98 return processedData, nil
99 }
100
101 return string(data), nil
102}
103
104// processZshHistory processa o histórico do Zsh para remover metadados e retornar apenas os comandos.
105func processZshHistory(data string) string {

Callers 3

processHistoryCommandMethod · 0.92
TestGetShellHistoryFunction · 0.85

Calls 4

GetShellHistoryFileFunction · 0.85
GetUserShellFunction · 0.85
processZshHistoryFunction · 0.85
ErrorfMethod · 0.80

Tested by 2

TestGetShellHistoryFunction · 0.68