Skip to content

Instantly share code, notes, and snippets.

@deverebor
Last active June 20, 2023 15:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deverebor/91817e5c02a1e82987c6989d4cf397a3 to your computer and use it in GitHub Desktop.
Save deverebor/91817e5c02a1e82987c6989d4cf397a3 to your computer and use it in GitHub Desktop.
PowerShell + Windows Terminal - Personal settings

My settings:

Plugins

  • posh-git (sintax highlight for git)
  • Terminal-Icons (show icons using dir or ls)
  • spaceship (theming)
  • PSReadlines (auto sugestions & auto complete)
  • PSFzf (recursive search)
  • z search (global search using z prefix to access some folder)

Theme

I created one version of spaceship for oh my posh. To use you only need download and put on the same directory of your powershell profile.

Your terminal will look like this

default

image

terminal icons

image

{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "lightYellow",
"properties": {
"macos": "mac"
},
"style": "plain",
"template": "{{ if .WSL }}WSL at {{ end }}{{.Icon}} ",
"type": "os"
},
{
"foreground": "lightYellow",
"style": "plain",
"template": "{{ .UserName }} ",
"type": "session"
},
{
"foreground": "cyan",
"properties": {
"style": "folder"
},
"style": "plain",
"template": "<#ffffff>in</> {{ .Path }} ",
"type": "path"
},
{
"type": "git",
"style": "plain",
"foreground": "#ff94df",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}{{ end }}",
"{{ if gt .Ahead 0 }}{{ end }}",
"{{ if gt .Behind 0 }}{{ end }}"
],
"template": "<#ffffff>on</> {{ .HEAD }}{{ .BranchStatus }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if and (.Working.Changed) (.Staging.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }} ",
"properties": {
"fetch_status": true,
"fetch_stash_count": true,
"fetch_upstream_icon": true,
"untracked_modes": {
"/Users/user/Projects/oh-my-posh/": "yes"
}
}
},
{
"foreground": "#ea2d2e",
"style": "powerline",
"template": "<#ffffff>via</> \ue738 {{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }} ",
"type": "java"
},
{
"foreground": "#906cff",
"style": "powerline",
"template": "<#ffffff>via</> \ue235 {{ if .Error }}{{ .Error }}{{ else }}{{ if .Venv }}{{ .Venv }} {{ end }}{{ .Full }}{{ end }} ",
"type": "python"
},
{
"foreground": "#76b367",
"style": "powerline",
"template": "<#ffffff>via</> \ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} ",
"type": "node"
}
],
"type": "prompt"
},
{
"alignment": "left",
"newline": false,
"segments": [
{
"foreground": "lightGreen",
"style": "plain",
"template": "\u276f",
"type": "text"
}
],
"type": "prompt"
}
],
"osc99": true,
"final_space": true,
"version": 2
}
# code ~/.config/starship.toml
format = """
[  ](bg:#303030 fg:#c7c7c7)\
$username\
[](bg:#303030 fg:#707070)\
$directory\
$git_branch\
$git_status\
[](#303030)\
"""
# Disable the blank line at the start of the prompt
add_newline = false
# You can also replace your username with a neat symbol like  or disable this
# and use the os module below
[username]
show_always = true
style_user = "fg:#b69676 bg:#303030"
style_root = "fg:white bg:#303030"
format = '[$user]($style)'
disabled = false
[status]
style = 'bg:#303030'
symbol = '[✘ ](fg:red bg:#303030)'
success_symbol = '[✔ ](fg:green bg:#303030)'
format = '[[$signal_name ](fg:red bg:#303030)$symbol]($style)'
map_symbol = false
disabled = false
[character]
success_symbol = '[✔](fg:green bg:#303030)'
error_symbol = '[✘](fg:red bg:#303030)'
[cmd_duration]
min_time = 1
style = 'bg:#303030 fg:#909090'
format = '[ took [$duration](bold fg:#909090 bg:#303030)  ]($style)'
[hostname]
ssh_only = false
style = 'fg:white bg:#303030'
format = '[@$hostname ]($style)'
disabled = false
# An alternative to the username module which displays a symbol that
# represents the current operating system
[os]
style = "bg:#303030"
disabled = true # Disabled by default
[directory]
style = "fg:white bg:#303030"
format = "[  $path ]($style)"
truncation_length = 9
truncation_symbol = "~/…/"
truncate_to_repo = true
home_symbol = '~'
# Here is how you can shorten some long paths by text replacement
# similar to mapped_locations in Oh My Posh:
[directory.substitutions]
#"~/" = "~./"
"~" = " ~"
[fill]
symbol = ' '
#symbol = '・'
[c]
symbol = ""
style = "bg:#303030"
format = '[ $symbol ]($style)'
[docker_context]
symbol = ""
style = "bg:#303030"
format = '[ $symbol $context ]($style) $path'
[git_branch]
style = "fg:white bg:#303030"
format = '[](fg:#707070 bg:#303030)[  ](fg:#D6D5CB bg:#303030)[](fg:#FFC0CB bg:#303030)[ $branch ](bold $style)'
truncation_length = 15
[git_status]
style = "fg:#0a96d6 bg:#303030"
conflicted = "~"
up_to_date = ""
untracked = "?"
ahead = "⇡${count}"
diverged = "⇕⇡${ahead_count}⇣${behind_count}"
behind = "⇣${count}"
stashed = "*"
modified = ""
staged = '[++\($count\)](fg:#56b60a bg:#303030)'
renamed = ""
deleted = ""
format = '[$all_status$ahead_behind ]($style)'
[golang]
symbol = "go"
style = "fg:#FFFFFF bg:#303030"
format = '[ $symbol ](bold $style)'
[java]
symbol = ""
style = "fg:#0a96d6 bg:#303030"
format = '[ $symbol ]($style)'
[nodejs]
symbol = ""
style = "fg:#0a96d6 bg:#303030"
format = '[ $symbol ]($style)'
[python]
# Display the version of python from inside a local venv.
#
# Note this will only work when the venv is inside the project and it will only
# work in the directory that contains the venv dir but maybe this is ok?
symbol = ''
style = "fg:#0a96d6 bg:#303030"
format = '[ $symbol ]($style)'
[rust]
symbol = ""
style = "fg:#0a96d6 bg:#303030"
format = '[ $symbol ]($style)'
[time]
disabled = false
time_format = "%R" # Hour:Minute Format
style = "bg:#303030 fg:#567676"
format = '[$time ]($style)'
# @author: deverebor
# @version: 2.0
# set PowerShell to UTF-8
[console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding
# Modules used
Import-Module posh-git
Import-Module -Name Terminal-Icons
# Configure starship
Invoke-Expression (&starship init powershell)
# Auto complete, keybinds and command history
Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadlineOption -HistorySearchCursorMovesToEnd
# Auto sugestions of PSReadline
Set-PSReadlineOption -ShowToolTips
Set-PSReadlineOption -PredictionViewStyle InlineView
Set-PSReadLineOption -PredictionSource History
# Utilities
# Function for finding the path of a given content.
function which ($command) {
Get-Command -Name $command -ErrorAction SilentlyContinue |
Select-Object -ExpandProperty Path -ErrorAction SilentlyContinue
}
# Function for create venv
function create-venv {
python '-m' 'venv' '.venv'
& '.\venv\Scripts\activate'
}
# Function to enter into a venv
function venv {
& '.\.venv\Scripts\activate'
}
@deverebor
Copy link
Author

Para escolher o seu tema visite: https://windowsterminalthemes.dev/

 "useAcrylic": true, 
 "acrylicOpacity": 0.75

São responsáveis pela opacidade do seu terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment