mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 08:43:00 +00:00
Use starship
This commit is contained in:
parent
e440b85d84
commit
1b66571411
14 changed files with 967 additions and 97 deletions
|
|
@ -1,9 +1,9 @@
|
|||
# aka PSReadLine
|
||||
# PSReadLineOptions
|
||||
Set-PSReadLineOption -EditMode vi # Vi Keybindings
|
||||
Set-PSReadLineOption -EditMode Vi # Vi Keybindings
|
||||
Set-PSReadLineOption -PredictionViewStyle ListView
|
||||
Set-PSReadLineOption -PredictionSource HistoryAndPlugin
|
||||
Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > "
|
||||
# Set-PSReadLineOption -ContinuationPrompt "`e[36m CR > " # Use Starship instead
|
||||
# PSReadLineKeyHandlers
|
||||
## Colemak hnei
|
||||
Set-PSReadLineKeyHandler -Chord "n" -Function NextHistory -ViMode Command
|
||||
|
|
|
|||
|
|
@ -10,4 +10,6 @@ ${function:down} = { Set-Location -Path ~/Downloads }
|
|||
${function:dt} = { Set-Location -Path ~/Desktop }
|
||||
${function:mytmp} = { Set-Location -Path ~/Temp }
|
||||
${function:one} = { Set-Location -Path ~/OneDrive }
|
||||
${function:doku} = { Set-Location -Path ~/doku && Get-ChildItem }
|
||||
${function:doku} = { Set-Location -Path ~/doku && Get-ChildItem }
|
||||
|
||||
Invoke-Expression (& { (zoxide init powershell | Out-String) })
|
||||
|
|
@ -1,86 +1,92 @@
|
|||
$promptTime = $true
|
||||
# $promptWeather = $false
|
||||
# Use starship to set prompt
|
||||
$ENV:STARSHIP_CONFIG = "$DOTFILES/.config/starship/starship_pwsh.toml"
|
||||
|
||||
function prompt {
|
||||
$prompt = "`e[35m"
|
||||
# Time
|
||||
if ($promptTime) {
|
||||
$promptTime = Get-Date -Format HH:mm
|
||||
$prompt += "`[$promptTime]"
|
||||
}
|
||||
# UserInfo
|
||||
$prompt += " $Env:Username @ $Env:Userdomain"
|
||||
# Directory
|
||||
$promptCurrentDirectory = $(PWD).Path
|
||||
$promptCurrentDirectory = $promptCurrentDirectory.Replace("$HOME", "~")
|
||||
$prompt += "`e[0m in `e[33m$promptCurrentDirectory "
|
||||
# Git
|
||||
if ($(git rev-parse --is-inside-work-tree 2> $null) -eq "true") {
|
||||
$prompt += "`e[32m`u{e702} $(git branch --show-current)"
|
||||
}
|
||||
# Conda
|
||||
if ( $Env:CONDA_PROMPT_MODIFIER ) {
|
||||
$promptConda = $Env:CONDA_PROMPT_MODIFIER.Replace("`(","").Replace(")","")
|
||||
$pythonVersion = $(python --version).Split(" ")[1]
|
||||
$prompt += " `e[33m`u{e73c} $promptConda $pythonVersion"
|
||||
}
|
||||
# Programming Language (by Get-ChildItem)
|
||||
## Python
|
||||
if (Test-Path -Path "$PWD\pyproject.toml") {
|
||||
$pythonVersion = $(python --version).Split(" ")[1]
|
||||
$prompt += " `e[33m`u{e73c} $pythonVersion"
|
||||
}
|
||||
## Node.js
|
||||
if (Test-Path -Path "$PWD\package.json") {
|
||||
$nodeVersion = $(node --version)
|
||||
$prompt += " `e[32m`u{e3a0} $nodeVersion"
|
||||
# Locked
|
||||
if (Test-Path -Path "$PWD\yarn.lock" || Test-Path -Path "$PWD\package-lock.json") {
|
||||
$prompt += "`u{f023}"
|
||||
}
|
||||
}
|
||||
## .NET
|
||||
### C Sharp
|
||||
if (Test-Path -Path "$PWD\*.csproj") {
|
||||
$dotnetVersion = $(dotnet --version)
|
||||
$prompt += " `e[34m`u{e648} $dotnetVersion"
|
||||
}
|
||||
### F Sharp
|
||||
if (Test-Path -Path "$PWD\*.fsproj") {
|
||||
$dotnetVersion = $(dotnet --version)
|
||||
$prompt += " `e[35m`u{e65a} $dotnetVersion"
|
||||
}
|
||||
## Rust
|
||||
if (Test-Path -Path "$PWD\Cargo.toml") {
|
||||
$rustVersion = $(cargo --version).Split(" ")[1]
|
||||
$prompt += " `e[31m`u{e7a8} $rustVersion"
|
||||
}
|
||||
## Java
|
||||
if (Test-Path -Path "$PWD\pom.xml" || Test-Path -Path "$PWD\build.gradle") {
|
||||
$javaVersion = $(java --version).Split(" ")[1]
|
||||
$prompt += " `e[31m`u{e738} $javaVersion"
|
||||
}
|
||||
## Makefile
|
||||
if (Test-Path -Path "$PWD\Makefile") {
|
||||
$prompt += " `e[32m`u{e673}"
|
||||
}
|
||||
if (Test-Path -Path "$PWD\CMakeLists.txt") {
|
||||
$prompt += " `e[32m `u{e61d}"
|
||||
}
|
||||
# Docker
|
||||
if (Test-Path -Path "$PWD\Dockerfile" || Test-Path -Path "$PWD\docker-compose.yml") {
|
||||
$prompt += " `e[33m`u{f21f}"
|
||||
}
|
||||
# Weather
|
||||
# if ( $global:promptWeather ) {
|
||||
# $prompt += $(Write-WeatherCurrent -City "Edinburgh" -Country "UK" -Unit "metric" -Inline -Apikey $Env:WEATHER_API_KEY)
|
||||
# }
|
||||
# Error on last command
|
||||
## TODO: Seems does not work
|
||||
if ($?) {
|
||||
$prompt += "`n`e[32m PS > `e[0m"
|
||||
} else {
|
||||
$prompt += "`n`e[31m PS > `e[0m"
|
||||
}
|
||||
return $prompt
|
||||
}
|
||||
Invoke-Expression (&starship init powershell)
|
||||
|
||||
# Below is the backup of original prompt function
|
||||
# $promptTime = $true
|
||||
# # $promptWeather = $false
|
||||
|
||||
# function prompt {
|
||||
# $prompt = "`e[35m"
|
||||
# # Time
|
||||
# if ($promptTime) {
|
||||
# $promptTime = Get-Date -Format HH:mm
|
||||
# $prompt += "`[$promptTime]"
|
||||
# }
|
||||
# # UserInfo
|
||||
# $prompt += " $Env:Username @ $Env:Userdomain"
|
||||
# # Directory
|
||||
# $promptCurrentDirectory = $(PWD).Path
|
||||
# $promptCurrentDirectory = $promptCurrentDirectory.Replace("$HOME", "~")
|
||||
# $prompt += "`e[0m in `e[33m$promptCurrentDirectory "
|
||||
# # Git
|
||||
# if ($(git rev-parse --is-inside-work-tree 2> $null) -eq "true") {
|
||||
# $prompt += "`e[32m`u{e702} $(git branch --show-current)"
|
||||
# }
|
||||
# # Conda
|
||||
# if ( $Env:CONDA_PROMPT_MODIFIER ) {
|
||||
# $promptConda = $Env:CONDA_PROMPT_MODIFIER.Replace("`(","").Replace(")","")
|
||||
# $pythonVersion = $(python --version).Split(" ")[1]
|
||||
# $prompt += " `e[33m`u{e73c} $promptConda $pythonVersion"
|
||||
# }
|
||||
# # Programming Language (by Get-ChildItem)
|
||||
# ## Python
|
||||
# if (Test-Path -Path "$PWD\pyproject.toml") {
|
||||
# $pythonVersion = $(python --version).Split(" ")[1]
|
||||
# $prompt += " `e[33m`u{e73c} $pythonVersion"
|
||||
# }
|
||||
# ## Node.js
|
||||
# if (Test-Path -Path "$PWD\package.json") {
|
||||
# $nodeVersion = $(node --version)
|
||||
# $prompt += " `e[32m`u{e3a0} $nodeVersion"
|
||||
# # Locked
|
||||
# if (Test-Path -Path "$PWD\yarn.lock" || Test-Path -Path "$PWD\package-lock.json") {
|
||||
# $prompt += "`u{f023}"
|
||||
# }
|
||||
# }
|
||||
# ## .NET
|
||||
# ### C Sharp
|
||||
# if (Test-Path -Path "$PWD\*.csproj") {
|
||||
# $dotnetVersion = $(dotnet --version)
|
||||
# $prompt += " `e[34m`u{e648} $dotnetVersion"
|
||||
# }
|
||||
# ### F Sharp
|
||||
# if (Test-Path -Path "$PWD\*.fsproj") {
|
||||
# $dotnetVersion = $(dotnet --version)
|
||||
# $prompt += " `e[35m`u{e65a} $dotnetVersion"
|
||||
# }
|
||||
# ## Rust
|
||||
# if (Test-Path -Path "$PWD\Cargo.toml") {
|
||||
# $rustVersion = $(cargo --version).Split(" ")[1]
|
||||
# $prompt += " `e[31m`u{e7a8} $rustVersion"
|
||||
# }
|
||||
# ## Java
|
||||
# if (Test-Path -Path "$PWD\pom.xml" || Test-Path -Path "$PWD\build.gradle") {
|
||||
# $javaVersion = $(java --version).Split(" ")[1]
|
||||
# $prompt += " `e[31m`u{e738} $javaVersion"
|
||||
# }
|
||||
# ## Makefile
|
||||
# if (Test-Path -Path "$PWD\Makefile") {
|
||||
# $prompt += " `e[32m`u{e673}"
|
||||
# }
|
||||
# if (Test-Path -Path "$PWD\CMakeLists.txt") {
|
||||
# $prompt += " `e[32m `u{e61d}"
|
||||
# }
|
||||
# # Docker
|
||||
# if (Test-Path -Path "$PWD\Dockerfile" || Test-Path -Path "$PWD\docker-compose.yml") {
|
||||
# $prompt += " `e[33m`u{f21f}"
|
||||
# }
|
||||
# # Weather
|
||||
# # if ( $global:promptWeather ) {
|
||||
# # $prompt += $(Write-WeatherCurrent -City "Edinburgh" -Country "UK" -Unit "metric" -Inline -Apikey $Env:WEATHER_API_KEY)
|
||||
# # }
|
||||
# # Error on last command
|
||||
# ## TODO: Seems does not work
|
||||
# if ($?) {
|
||||
# $prompt += "`n`e[32m PS > `e[0m"
|
||||
# } else {
|
||||
# $prompt += "`n`e[31m PS > `e[0m"
|
||||
# }
|
||||
# return $prompt
|
||||
# }
|
||||
23
powershell/readme.md
Normal file
23
powershell/readme.md
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# PowerShell Profile
|
||||
|
||||
This is the cross-platform PowerShell profile for PowerShell Core
|
||||
|
||||
```text
|
||||
.
|
||||
├── Aliases.ps1
|
||||
├── Keymap.ps1 # keymaps, optimize for Vi-Mode and Colemak
|
||||
├── Modules.ps1
|
||||
├── Navigation.ps1
|
||||
├── Prompt.ps1
|
||||
├── readme.md
|
||||
└── Scripts.ps1
|
||||
|
||||
1 directory, 7 files
|
||||
```
|
||||
|
||||
| Keymap | Action | Mode |
|
||||
| --- | --- | --- |
|
||||
| `^a` | To Beginning of Line | All |
|
||||
| `^e` | To End of Line | All |
|
||||
| `^[` | To Normal Mode | Insert |
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue