Ruta
Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? Reportar problema →
Qué hace
Muestra la ruta actual.
Configuración de ejemplo
- json
- yaml
- toml
{
"type": "path",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#ffffff",
"background": "#61AFEF",
"options": {
"style": "folder",
"mapped_locations": {
"C:\\temp": ""
}
}
}
type: path
style: powerline
powerline_symbol:
foreground: "#ffffff"
background: "#61AFEF"
options:
style: folder
mapped_locations:
C:\temp:
type = "path"
style = "powerline"
powerline_symbol = ""
foreground = "#ffffff"
background = "#61AFEF"
[options]
style = "folder"
[options.mapped_locations]
"C:\\temp" = ""
Opciones
| Name | Type | Default | Description |
|---|---|---|---|
folder_separator_icon | string | / | the symbol to use as a separator between folders |
folder_separator_template | string | the template to use as a separator between folders | |
home_icon | string | ~ | the icon to display when at $HOME |
folder_icon | string | .. | the icon to use as a folder indication |
windows_registry_icon | string | \uF013 | the icon to display when in the Windows registry |
style | enum | agnoster | how to display the current path |
mixed_threshold | number | 4 | the maximum length of a path segment that will be displayed when using Mixed |
max_depth | number | 1 | maximum path depth to display before shortening when using agnoster_short |
max_width | any | 0 | maximum path length to display when using powerlevel or agnoster, can leverage templates |
hide_root_location | boolean | false | hides the root location if it doesn't fit in the last max_depth folders when using agnoster_short |
cycle | []string | a list of color overrides to cycle through to colorize the individual path folders, e.g. [ "#ffffff,#111111" ] | |
cycle_folder_separator | boolean | false | colorize the folder_separator_icon as well when using a cycle |
folder_format | string | %s | format to use on individual path folders |
edge_format | string | %s | format to use on the first and last folder of the path |
left_format | string | %s | format to use on the first folder of the path - defaults to edge_format |
right_format | string | %s | format to use on the last folder of the path - defaults to edge_format |
gitdir_format | string | format to use for a git root directory | |
display_cygpath | boolean | false | display the Cygwin style path using cygpath -u $PWD |
display_root | boolean | false | display the root / on Unix systems |
dir_length | number | 1 | the length of the directory name to display when using fish |
full_length_dirs | number | 1 | indicates how many full length directory names should be displayed when using fish |
Ubicaciones mapeadas
Permite reemplazar una ubicación con un icono/cadena. Verifica si la ruta actual comienza con elementos específicos y los reemplaza con el icono/cadena si coincide. Para evitar conflictos con anulaciones anidadas, Oh My Posh ordenará la lista de ubicaciones mapeadas antes de realizar reemplazos.
| Name | Type | Default | Description |
|---|---|---|---|
mapped_locations_enabled | boolean | true | replace known locations in the path with the replacements before applying the style |
mapped_locations | object | custom glyph/text for specific paths. Works regardless of the mapped_locations_enabled |
en la configuración.
Por ejemplo, para reemplazar C:\Users\Leet\GitHub con un icono de GitHub:
- json
- yaml
- toml
{
"mapped_locations": {
"C:\\Users\\Leet\\GitHub": ""
}
}
mapped_locations:
C:\Users\Leet\GitHub:
[mapped_locations]
"C:\\Users\\Leet\\GitHub" = ""
Cómo funciona
-
Para compatibilidad multiplataforma, usa
/como separador de rutas. Oh My Posh adaptará automáticamente los separadores según el sistema operativo. -
Para coincidir con subdirectorios, usa
*como comodín. Ejemplo:"C:/Users/Bill/*": "$"convertiráC:/Users/Bill/Downloadsen$/Downloads, pero mantendráC:/Users/Billsin cambios. -
El carácter
~al inicio coincidirá con el directorio de usuario. -
La coincidencia es insensible a mayúsculas en Windows y macOS, pero sensible en otros sistemas. Ejemplo: para el usuario Bill (cuenta
Billen Windows ybillen Linux),~/Foocoincidirá conC:\Users\Bill\FoooC:\Users\Bill\fooen Windows, pero solo con/home/bill/Fooen Linux.
Para evitar distorsionar elementos de ruta, si usas etiquetas de estilo (ej. <lightGreen>...</>) en valores de reemplazo,
evita usar caracteres de cheurón (</>) en la propiedad folder_separator_icon, y viceversa.
Usando expresiones regulares
Para casos complejos, usa el prefijo re: con grupos de captura en expresiones regulares.
Utiliza el paquete regexp de Golang con sintaxis admitida. El valor de reemplazo será el primer grupo de captura;
los grupos posteriores se ignoran.
Ejemplo: "re:(C:/[0-9]+/Foo)": "#" coincidirá con C:\123\Foo\Bar y lo reemplazará por #\Bar. La ruta de coincidencia
siempre usa /, independientemente del sistema operativo, permitiendo coincidencias multiplataforma.
Como en reemplazos estándar, la coincidencia es insensible a mayúsculas en Windows y unidades montadas con WSL, pero sensible en otros sistemas operativos.
Estilo
El estilo define cómo se muestra la ruta. Existen 10 variantes basadas en experiencias previas y temas populares:
-
agnoster -
agnoster_full -
agnoster_short -
agnoster_left -
full -
folder -
mixed -
letter -
unique -
powerlevel -
fish
Agnoster
Muestra cada carpeta intermedia como folder_icon separada por folder_separator_icon.
La primera y última carpeta (actual) siempre se muestran como texto.
Agnoster Full
Muestra todos los nombres de carpeta separados por folder_separator_icon.
Agnoster Short
Cuando la profundidad supera max_depth niveles, muestra un folder_icon (si hide_root_location es false, lo que significa que la carpeta raíz no cuenta para la profundidad) seguido de los nombres de las últimas max_depth carpetas, separados por el folder_separator_icon.
Agnoster Left
Muestra cada carpeta como folder_icon separado por folder_separator_icon. Solo el nombre de la primera carpeta y su carpeta hija inmediata se muestran completos.
Full
Muestra el directorio de trabajo actual como cadena completa con cada carpeta separada por folder_separator_icon.
Folder
Muestra el nombre de la carpeta actual.
Mixed
Funciona como agnoster, pero para nombres de carpetas intermedios suficientemente cortos, se mostrarán completos. La longitud máxima para mostrar carpetas se controla con la propiedad mixed_threshold.
Letter
Funciona como agnoster_full, pero muestra cada nombre de carpeta usando solo la primera letra, excepto cuando el nombre empieza con símbolo o icono. Específicamente, el último nombre (carpeta actual) siempre se muestra completo.
-
folderse acortará af -
.configse acortará a.c -
__pycache__se acortará a__p -
➼ folderse acortará a➼ f
Unique
Funciona como letter, pero asegura que cada nombre de carpeta sea el valor único más corto posible.
La unicidad se refiere a la ruta mostrada, así C:\dev\dev\dev\development se mostrará como C\d\de\dev\development (en vez de C\d\d\d\development como en Letter). La unicidad no se refiere a otras carpetas en el mismo nivel, así que si existen C:\projectA\dev y C:\projectB\dev, ambas se mostrarán como C\p\dev.
Powerlevel
Funciona como unique, pero detiene el acortamiento al alcanzar max_width.
Fish
Funciona como letter, pero muestra los primeros dir_length caracteres de cada nombre de carpeta, excepto las últimas carpetas especificadas por full_length_dirs, que se muestran completas. Inspirado en el PWD del shell Fish.
Plantilla (info)
{{ .Path }}
Propiedades
| Name | Type | Description |
|---|---|---|
.Path | string | the current directory (based on the style property) |
.Parent | string | the current directory's parent folder which ends with a path separator (designed for use with style folder, it is empty if .Path contains only one single element) |
.RootDir | boolean | true if we're at the root directory (no parent) |
.Location | string | the current directory (raw value) |
.StackCount | int | the stack count |
.Writable | boolean | is the current directory writable by the user or not |
.Format | function | format any path based on the segment's settings (e.g. {{ .Format .Segments.Git.RelativeDir }}) |