GetShellHistoryFile retorna o caminho do arquivo de histórico do shell.
()
| 54 | |
| 55 | // GetShellHistoryFile retorna o caminho do arquivo de histórico do shell. |
| 56 | func 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. |
| 80 | func GetShellHistory() (string, error) { |
no test coverage detected