Bourne Again SHell RC#
Bashrc steht für Bourne Again SHell RC. Der Begriff RC leitet sich historisch von Run Commands (oder Run Control) ab, was auf ältere Unix-Systeme (CTSS) zurückgeht.
Die .bashrc ist eine versteckte Konfigurationsdatei im Home (~/.bashrc), die das Verhalten der Bash-Shell in Linux steuert. Sie wird bei jedem Start einer interaktiven Shell (z. B. beim Öffnen eines neuen Terminalfensters) automatisch ausgeführt, um die Benutzereinstellungen zu laden.
Ich mage es, wenn der aktuelle Zeitstempel, der Username und der Computername gefolgt vom Pfad angezeigt wird:
[14:02:40][tinu@imac]:~/code$ Dazu ergänze ich die .bashrc mit [\t][\u@\h]: \w\a\]:
# for examples
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\][\t][\u@\h]\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}[\t][\u@\h]:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}[\t][\u@\h]: \w\a\]$PS1"
;;
*)
;;
esacAusserdem mag ich es, wenn das Terminal beim Starten mir gleich aufgezeigt, ob Updates vorhanden sind:
# Zeigt Anzahl der verfuegbaren Updates an, falls vorhanden
echo "========================================================================================"
echo "| Kernel: $(uname -r)"
UPDATES=$(apt list --upgradable 2>/dev/null | awk -F/ 'NR>1 {print $1}')
if [ -n "$UPDATES" ]; then
COUNT=$(printf '%s\n' "$UPDATES" | wc -l)
echo "========================================================================================"
echo
echo "Information: $COUNT Package-Updates available."
echo
echo "$UPDATES"
echo
echo "Run ansible-playbook playbooks/basics.yml --ask-become-pass to update the system."
fi
echo "========================================================================================"PowerShell-Profile#
In PowerShell verwende ich für die Einstellungen meines Terminals die Datei $profile (bei Linux unter /home/USERNAME/.config/powershell/Microsoft.PowerShell_profile.ps1). Hier meine Einstellungen für PowerShell:
function Test-IsElevated {
if($IsWindows){
$user = [Security.Principal.WindowsIdentity]::GetCurrent()
$ret = (New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
if($IsLinux -or $IsMacOS){
$ret = (id -u) -eq 0
}
$ret
}
function prompt{
if (Test-IsElevated) {
$color = 'Red'
}
else{
$color = 'Green'
}
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Import-Module -Name CompletionPredictor
Set-PSReadLineOption -PredictionViewStyle ListView
$Version = "$($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor).$($PSVersionTable.PSVersion.Patch)"
$homePath = (Get-Location).Path -replace "^$([regex]::Escape($HOME))", "~"
Write-Host "[$(Get-Date -f 'HH:mm:ss')] " -ForegroundColor $color -NoNewline
if($global:defaultVIServer.Name){
Write-Host "[$([Environment]::UserName)@$([Environment]::MachineName)#$($global:defaultVIServer.Name)] " -ForegroundColor $color -NoNewline
}else{
Write-Host "[$([Environment]::UserName)@$([Environment]::MachineName)] " -ForegroundColor $color -NoNewline
}
Write-Host ("I") -nonewline
Write-Host (([char]9829)) -ForegroundColor $color -nonewline
Write-Host ("PS ") -nonewline
Write-Host ("$($Version):") -ForegroundColor $color -nonewline
Write-Host ($homePath) -foregroundcolor blue -nonewline
Write-Host (">") -foregroundcolor white -nonewline
return " "
}