profile method
Get current shell type and its configuration file path (cross-platform)
Returns null if unable to determine or unsupported.
Implementation
(String, String)? profile() {
if (isWindows) return ('windows', '');
final shellPath = environ['SHELL'] ?? '';
String shell = 'sh';
String profile = p.join(homeDir, '.profile');
if (shellPath.isEmpty) logger.trace("w, SHELL not set. use default.");
final currShell = p.basename(shellPath);
switch (currShell) {
case 'zsh':
profile = p.join(homeDir, '.zprofile');
if (!File(profile).existsSync()) profile = p.join(homeDir, '.zshrc');
break;
case 'bash':
profile = p.join(homeDir, '.bash_profile');
if (!File(profile).existsSync()) profile = p.join(homeDir, '.profile');
break;
case 'fish':
profile = p.join(homeDir, '.config', 'fish', 'config.fish');
break;
case 'sh':
case 'dash':
case 'ash':
default:
logger.trace("w, unsupported shell: $currShell.");
}
return ((shell == currShell) ? shell : currShell, profile);
}