mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
parent
729eef0c93
commit
24651a6144
9 changed files with 157 additions and 219 deletions
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Packaging
|
### Packaging
|
||||||
|
|
||||||
- Minimum Rust version has been bumped to 1.36.0
|
- Minimum Rust version has been bumped to 1.36.0
|
||||||
|
- Config is not generated anymore, please consider distributing the alacritty.yml as documentation
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
|
@ -70,6 +71,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
- Bindings for Super/Command + F1-F12
|
- Bindings for Super/Command + F1-F12
|
||||||
|
- Automatic config generation
|
||||||
|
|
||||||
## 0.3.3
|
## 0.3.3
|
||||||
|
|
||||||
|
|
17
README.md
17
README.md
|
@ -152,25 +152,16 @@ properly.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Although it's possible the default configuration would work on your system,
|
You can find the default configuration file with documentation for all available
|
||||||
you'll probably end up wanting to customize it anyhow. There is a default
|
fields on the [GitHub releases page](https://github.com/jwilm/alacritty/releases) for each release.
|
||||||
`alacritty.yml` at the Git repository root. Alacritty looks for the
|
|
||||||
configuration file at the following paths:
|
Alacritty looks for the configuration file at the following paths:
|
||||||
|
|
||||||
1. `$XDG_CONFIG_HOME/alacritty/alacritty.yml`
|
1. `$XDG_CONFIG_HOME/alacritty/alacritty.yml`
|
||||||
2. `$XDG_CONFIG_HOME/alacritty.yml`
|
2. `$XDG_CONFIG_HOME/alacritty.yml`
|
||||||
3. `$HOME/.config/alacritty/alacritty.yml`
|
3. `$HOME/.config/alacritty/alacritty.yml`
|
||||||
4. `$HOME/.alacritty.yml`
|
4. `$HOME/.alacritty.yml`
|
||||||
|
|
||||||
If none of these paths are found then
|
|
||||||
`$XDG_CONFIG_HOME/alacritty/alacritty.yml` is created once Alacritty is first
|
|
||||||
run. On most systems this often defaults to
|
|
||||||
`$HOME/.config/alacritty/alacritty.yml`.
|
|
||||||
|
|
||||||
Many configuration options will take effect immediately upon saving changes to
|
|
||||||
the config file. For more information about the config file structure, refer to
|
|
||||||
the default config file.
|
|
||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
On Windows the config file is located at:
|
On Windows the config file is located at:
|
||||||
|
|
184
alacritty.yml
184
alacritty.yml
|
@ -12,14 +12,14 @@
|
||||||
# available, otherwise `xterm-256color` is used.
|
# available, otherwise `xterm-256color` is used.
|
||||||
#TERM: xterm-256color
|
#TERM: xterm-256color
|
||||||
|
|
||||||
window:
|
#window:
|
||||||
# Window dimensions (changes require restart)
|
# Window dimensions (changes require restart)
|
||||||
#
|
#
|
||||||
# Specified in number of columns/lines, not pixels.
|
# Specified in number of columns/lines, not pixels.
|
||||||
# If both are `0`, this setting is ignored.
|
# If both are `0`, this setting is ignored.
|
||||||
dimensions:
|
#dimensions:
|
||||||
columns: 0
|
# columns: 0
|
||||||
lines: 0
|
# lines: 0
|
||||||
|
|
||||||
# Window position (changes require restart)
|
# Window position (changes require restart)
|
||||||
#
|
#
|
||||||
|
@ -33,12 +33,12 @@ window:
|
||||||
#
|
#
|
||||||
# Blank space added around the window in pixels. This padding is scaled
|
# Blank space added around the window in pixels. This padding is scaled
|
||||||
# by DPI and the specified value is always added at both opposing sides.
|
# by DPI and the specified value is always added at both opposing sides.
|
||||||
padding:
|
#padding:
|
||||||
x: 0
|
# x: 0
|
||||||
y: 0
|
# y: 0
|
||||||
|
|
||||||
# Spread additional padding evenly around the terminal content.
|
# Spread additional padding evenly around the terminal content.
|
||||||
dynamic_padding: false
|
#dynamic_padding: false
|
||||||
|
|
||||||
# Window decorations
|
# Window decorations
|
||||||
#
|
#
|
||||||
|
@ -49,7 +49,7 @@ window:
|
||||||
# Values for `decorations` (macOS only):
|
# Values for `decorations` (macOS only):
|
||||||
# - transparent: Title bar, transparent background and title bar buttons
|
# - transparent: Title bar, transparent background and title bar buttons
|
||||||
# - buttonless: Title bar, transparent background, but no title bar buttons
|
# - buttonless: Title bar, transparent background, but no title bar buttons
|
||||||
decorations: full
|
#decorations: full
|
||||||
|
|
||||||
# Startup Mode (changes require restart)
|
# Startup Mode (changes require restart)
|
||||||
#
|
#
|
||||||
|
@ -60,32 +60,32 @@ window:
|
||||||
#
|
#
|
||||||
# Values for `startup_mode` (macOS only):
|
# Values for `startup_mode` (macOS only):
|
||||||
# - SimpleFullscreen
|
# - SimpleFullscreen
|
||||||
startup_mode: Windowed
|
#startup_mode: Windowed
|
||||||
|
|
||||||
# Window title
|
# Window title
|
||||||
#title: Alacritty
|
#title: Alacritty
|
||||||
|
|
||||||
# Window class (Linux only):
|
# Window class (Linux only):
|
||||||
class:
|
#class:
|
||||||
# Application instance name
|
# Application instance name
|
||||||
instance: Alacritty
|
#instance: Alacritty
|
||||||
# General application class
|
# General application class
|
||||||
general: Alacritty
|
#general: Alacritty
|
||||||
|
|
||||||
# GTK theme variant (Linux only)
|
# GTK theme variant (Linux only)
|
||||||
#
|
#
|
||||||
# Override the variant of the GTK theme. Commonly supported values are `dark` and `light`.
|
# Override the variant of the GTK theme. Commonly supported values are `dark` and `light`.
|
||||||
# Set this to `None` to use the default theme variant.
|
# Set this to `None` to use the default theme variant.
|
||||||
gtk_theme_variant: None
|
#gtk_theme_variant: None
|
||||||
|
|
||||||
scrolling:
|
#scrolling:
|
||||||
# Maximum number of lines in the scrollback buffer.
|
# Maximum number of lines in the scrollback buffer.
|
||||||
# Specifying '0' will disable scrolling.
|
# Specifying '0' will disable scrolling.
|
||||||
history: 10000
|
#history: 10000
|
||||||
|
|
||||||
# Number of lines the viewport will move for every line scrolled when
|
# Number of lines the viewport will move for every line scrolled when
|
||||||
# scrollback is enabled (history > 0).
|
# scrollback is enabled (history > 0).
|
||||||
multiplier: 3
|
#multiplier: 3
|
||||||
|
|
||||||
# Faux Scrolling
|
# Faux Scrolling
|
||||||
#
|
#
|
||||||
|
@ -94,10 +94,10 @@ scrolling:
|
||||||
# to allow mouse scrolling for applications like `man`.
|
# to allow mouse scrolling for applications like `man`.
|
||||||
#
|
#
|
||||||
# Specifying `0` will disable faux scrolling.
|
# Specifying `0` will disable faux scrolling.
|
||||||
faux_multiplier: 3
|
#faux_multiplier: 3
|
||||||
|
|
||||||
# Scroll to the bottom when new text is written to the terminal.
|
# Scroll to the bottom when new text is written to the terminal.
|
||||||
auto_scroll: false
|
#auto_scroll: false
|
||||||
|
|
||||||
# Spaces per Tab (changes require restart)
|
# Spaces per Tab (changes require restart)
|
||||||
#
|
#
|
||||||
|
@ -106,10 +106,10 @@ scrolling:
|
||||||
# Some applications, like Emacs, rely on knowing about the width of a tab.
|
# Some applications, like Emacs, rely on knowing about the width of a tab.
|
||||||
# To prevent unexpected behavior in these applications, it's also required to
|
# To prevent unexpected behavior in these applications, it's also required to
|
||||||
# change the `it` value in terminfo when altering this setting.
|
# change the `it` value in terminfo when altering this setting.
|
||||||
tabspaces: 8
|
#tabspaces: 8
|
||||||
|
|
||||||
# Font configuration (changes require restart)
|
# Font configuration (changes require restart)
|
||||||
font:
|
#font:
|
||||||
# Normal (roman) font face
|
# Normal (roman) font face
|
||||||
#normal:
|
#normal:
|
||||||
# Font family
|
# Font family
|
||||||
|
@ -157,20 +157,20 @@ font:
|
||||||
#style: Bold Italic
|
#style: Bold Italic
|
||||||
|
|
||||||
# Point size
|
# Point size
|
||||||
size: 11.0
|
#size: 11.0
|
||||||
|
|
||||||
# Offset is the extra space around each character. `offset.y` can be thought of
|
# Offset is the extra space around each character. `offset.y` can be thought of
|
||||||
# as modifying the line spacing, and `offset.x` as modifying the letter spacing.
|
# as modifying the line spacing, and `offset.x` as modifying the letter spacing.
|
||||||
offset:
|
#offset:
|
||||||
x: 0
|
# x: 0
|
||||||
y: 0
|
# y: 0
|
||||||
|
|
||||||
# Glyph offset determines the locations of the glyphs within their cells with
|
# Glyph offset determines the locations of the glyphs within their cells with
|
||||||
# the default being at the bottom. Increasing `x` moves the glyph to the right,
|
# the default being at the bottom. Increasing `x` moves the glyph to the right,
|
||||||
# increasing `y` moves the glyph upwards.
|
# increasing `y` moves the glyph upwards.
|
||||||
glyph_offset:
|
#glyph_offset:
|
||||||
x: 0
|
# x: 0
|
||||||
y: 0
|
# y: 0
|
||||||
|
|
||||||
# Thin stroke font rendering (macOS only)
|
# Thin stroke font rendering (macOS only)
|
||||||
#
|
#
|
||||||
|
@ -186,17 +186,17 @@ font:
|
||||||
#
|
#
|
||||||
# This is a global setting and will require a log out or restart to take
|
# This is a global setting and will require a log out or restart to take
|
||||||
# effect.
|
# effect.
|
||||||
use_thin_strokes: true
|
#use_thin_strokes: true
|
||||||
|
|
||||||
# If `true`, bold text is drawn using the bright color variants.
|
# If `true`, bold text is drawn using the bright color variants.
|
||||||
draw_bold_text_with_bright_colors: true
|
#draw_bold_text_with_bright_colors: true
|
||||||
|
|
||||||
# Colors (Tomorrow Night Bright)
|
# Colors (Tomorrow Night Bright)
|
||||||
colors:
|
#colors:
|
||||||
# Default colors
|
# Default colors
|
||||||
primary:
|
#primary:
|
||||||
background: '0x000000'
|
# background: '0x000000'
|
||||||
foreground: '0xeaeaea'
|
# foreground: '0xeaeaea'
|
||||||
|
|
||||||
# Bright and dim foreground colors
|
# Bright and dim foreground colors
|
||||||
#
|
#
|
||||||
|
@ -224,26 +224,26 @@ colors:
|
||||||
# background: '0x404040'
|
# background: '0x404040'
|
||||||
|
|
||||||
# Normal colors
|
# Normal colors
|
||||||
normal:
|
#normal:
|
||||||
black: '0x000000'
|
# black: '0x000000'
|
||||||
red: '0xd54e53'
|
# red: '0xd54e53'
|
||||||
green: '0xb9ca4a'
|
# green: '0xb9ca4a'
|
||||||
yellow: '0xe6c547'
|
# yellow: '0xe6c547'
|
||||||
blue: '0x7aa6da'
|
# blue: '0x7aa6da'
|
||||||
magenta: '0xc397d8'
|
# magenta: '0xc397d8'
|
||||||
cyan: '0x70c0ba'
|
# cyan: '0x70c0ba'
|
||||||
white: '0xeaeaea'
|
# white: '0xeaeaea'
|
||||||
|
|
||||||
# Bright colors
|
# Bright colors
|
||||||
bright:
|
#bright:
|
||||||
black: '0x666666'
|
# black: '0x666666'
|
||||||
red: '0xff3334'
|
# red: '0xff3334'
|
||||||
green: '0x9ec400'
|
# green: '0x9ec400'
|
||||||
yellow: '0xe7c547'
|
# yellow: '0xe7c547'
|
||||||
blue: '0x7aa6da'
|
# blue: '0x7aa6da'
|
||||||
magenta: '0xb77ee0'
|
# magenta: '0xb77ee0'
|
||||||
cyan: '0x54ced6'
|
# cyan: '0x54ced6'
|
||||||
white: '0xffffff'
|
# white: '0xffffff'
|
||||||
|
|
||||||
# Dim colors
|
# Dim colors
|
||||||
#
|
#
|
||||||
|
@ -267,7 +267,7 @@ colors:
|
||||||
# Example:
|
# Example:
|
||||||
# `- { index: 16, color: '0xff00ff' }`
|
# `- { index: 16, color: '0xff00ff' }`
|
||||||
#
|
#
|
||||||
indexed_colors: []
|
#indexed_colors: []
|
||||||
|
|
||||||
# Visual Bell
|
# Visual Bell
|
||||||
#
|
#
|
||||||
|
@ -290,41 +290,41 @@ colors:
|
||||||
# - Linear
|
# - Linear
|
||||||
#
|
#
|
||||||
# Specifying a `duration` of `0` will disable the visual bell.
|
# Specifying a `duration` of `0` will disable the visual bell.
|
||||||
visual_bell:
|
#visual_bell:
|
||||||
animation: EaseOutExpo
|
# animation: EaseOutExpo
|
||||||
duration: 0
|
# duration: 0
|
||||||
color: '0xffffff'
|
# color: '0xffffff'
|
||||||
|
|
||||||
# Background opacity
|
# Background opacity
|
||||||
#
|
#
|
||||||
# Window opacity as a floating point number from `0.0` to `1.0`.
|
# Window opacity as a floating point number from `0.0` to `1.0`.
|
||||||
# The value `0.0` is completely transparent and `1.0` is opaque.
|
# The value `0.0` is completely transparent and `1.0` is opaque.
|
||||||
background_opacity: 1.0
|
#background_opacity: 1.0
|
||||||
|
|
||||||
selection:
|
#selection:
|
||||||
semantic_escape_chars: ",│`|:\"' ()[]{}<>\t"
|
#semantic_escape_chars: ",│`|:\"' ()[]{}<>\t"
|
||||||
|
|
||||||
# When set to `true`, selected text will be copied to the primary clipboard.
|
# When set to `true`, selected text will be copied to the primary clipboard.
|
||||||
save_to_clipboard: false
|
#save_to_clipboard: false
|
||||||
|
|
||||||
# Allow terminal applications to change Alacritty's window title.
|
# Allow terminal applications to change Alacritty's window title.
|
||||||
dynamic_title: true
|
#dynamic_title: true
|
||||||
|
|
||||||
cursor:
|
#cursor:
|
||||||
# Cursor style
|
# Cursor style
|
||||||
#
|
#
|
||||||
# Values for `style`:
|
# Values for `style`:
|
||||||
# - ▇ Block
|
# - ▇ Block
|
||||||
# - _ Underline
|
# - _ Underline
|
||||||
# - | Beam
|
# - | Beam
|
||||||
style: Block
|
#style: Block
|
||||||
|
|
||||||
# If this is `true`, the cursor will be rendered as a hollow box when the
|
# If this is `true`, the cursor will be rendered as a hollow box when the
|
||||||
# window is not focused.
|
# window is not focused.
|
||||||
unfocused_hollow: true
|
#unfocused_hollow: true
|
||||||
|
|
||||||
# Live config reload (changes require restart)
|
# Live config reload (changes require restart)
|
||||||
live_config_reload: true
|
#live_config_reload: true
|
||||||
|
|
||||||
# Shell
|
# Shell
|
||||||
#
|
#
|
||||||
|
@ -344,7 +344,7 @@ live_config_reload: true
|
||||||
#
|
#
|
||||||
# Directory the shell is started in. If this is unset, or `None`, the working
|
# Directory the shell is started in. If this is unset, or `None`, the working
|
||||||
# directory of the parent process will be used.
|
# directory of the parent process will be used.
|
||||||
working_directory: None
|
#working_directory: None
|
||||||
|
|
||||||
# Windows 10 ConPTY backend (Windows only)
|
# Windows 10 ConPTY backend (Windows only)
|
||||||
#
|
#
|
||||||
|
@ -355,17 +355,17 @@ working_directory: None
|
||||||
#
|
#
|
||||||
# Alacritty will fall back to the WinPTY automatically if the ConPTY
|
# Alacritty will fall back to the WinPTY automatically if the ConPTY
|
||||||
# backend cannot be initialized.
|
# backend cannot be initialized.
|
||||||
enable_experimental_conpty_backend: false
|
#enable_experimental_conpty_backend: false
|
||||||
|
|
||||||
# Send ESC (\x1b) before characters when alt is pressed.
|
# Send ESC (\x1b) before characters when alt is pressed.
|
||||||
alt_send_esc: true
|
#alt_send_esc: true
|
||||||
|
|
||||||
debug:
|
#debug:
|
||||||
# Display the time it takes to redraw each frame.
|
# Display the time it takes to redraw each frame.
|
||||||
render_timer: false
|
#render_timer: false
|
||||||
|
|
||||||
# Keep the log file after quitting Alacritty.
|
# Keep the log file after quitting Alacritty.
|
||||||
persistent_logging: false
|
#persistent_logging: false
|
||||||
|
|
||||||
# Log level
|
# Log level
|
||||||
#
|
#
|
||||||
|
@ -376,27 +376,27 @@ debug:
|
||||||
# - Info
|
# - Info
|
||||||
# - Debug
|
# - Debug
|
||||||
# - Trace
|
# - Trace
|
||||||
log_level: Warn
|
#log_level: Warn
|
||||||
|
|
||||||
# Print all received window events.
|
# Print all received window events.
|
||||||
print_events: false
|
#print_events: false
|
||||||
|
|
||||||
# Record all characters and escape sequences as test data.
|
# Record all characters and escape sequences as test data.
|
||||||
ref_test: false
|
#ref_test: false
|
||||||
|
|
||||||
mouse:
|
#mouse:
|
||||||
# Click settings
|
# Click settings
|
||||||
#
|
#
|
||||||
# The `double_click` and `triple_click` settings control the time
|
# The `double_click` and `triple_click` settings control the time
|
||||||
# alacritty should wait for accepting multiple clicks as one double
|
# alacritty should wait for accepting multiple clicks as one double
|
||||||
# or triple click.
|
# or triple click.
|
||||||
double_click: { threshold: 300 }
|
#double_click: { threshold: 300 }
|
||||||
triple_click: { threshold: 300 }
|
#triple_click: { threshold: 300 }
|
||||||
|
|
||||||
# If this is `true`, the cursor is temporarily hidden when typing.
|
# If this is `true`, the cursor is temporarily hidden when typing.
|
||||||
hide_when_typing: false
|
#hide_when_typing: false
|
||||||
|
|
||||||
url:
|
#url:
|
||||||
# URL launcher
|
# URL launcher
|
||||||
#
|
#
|
||||||
# This program is executed when clicking on a text which is recognized as a URL.
|
# This program is executed when clicking on a text which is recognized as a URL.
|
||||||
|
@ -416,7 +416,7 @@ mouse:
|
||||||
#
|
#
|
||||||
# These are the modifiers that need to be held down for opening URLs when clicking
|
# These are the modifiers that need to be held down for opening URLs when clicking
|
||||||
# on them. The available modifiers are documented in the key binding section.
|
# on them. The available modifiers are documented in the key binding section.
|
||||||
modifiers: None
|
#modifiers: None
|
||||||
|
|
||||||
# Mouse bindings
|
# Mouse bindings
|
||||||
#
|
#
|
||||||
|
@ -437,8 +437,8 @@ mouse:
|
||||||
# And optionally:
|
# And optionally:
|
||||||
#
|
#
|
||||||
# - `mods` (see key bindings)
|
# - `mods` (see key bindings)
|
||||||
mouse_bindings:
|
#mouse_bindings:
|
||||||
- { mouse: Middle, action: PasteSelection }
|
# - { mouse: Middle, action: PasteSelection }
|
||||||
|
|
||||||
# Key bindings
|
# Key bindings
|
||||||
#
|
#
|
||||||
|
@ -539,7 +539,7 @@ mouse_bindings:
|
||||||
# binding with the same triggers is defined. To unset a default binding, it can
|
# binding with the same triggers is defined. To unset a default binding, it can
|
||||||
# be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for
|
# be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for
|
||||||
# a no-op if you do not wish to receive input characters for that binding.
|
# a no-op if you do not wish to receive input characters for that binding.
|
||||||
key_bindings:
|
#key_bindings:
|
||||||
# (Windows/Linux only)
|
# (Windows/Linux only)
|
||||||
#- { key: V, mods: Control|Shift, action: Paste }
|
#- { key: V, mods: Control|Shift, action: Paste }
|
||||||
#- { key: C, mods: Control|Shift, action: Copy }
|
#- { key: C, mods: Control|Shift, action: Copy }
|
||||||
|
@ -565,11 +565,11 @@ key_bindings:
|
||||||
#- { key: W, mods: Command, action: Quit }
|
#- { key: W, mods: Command, action: Quit }
|
||||||
#- { key: F, mods: Command|Control, action: ToggleFullscreen }
|
#- { key: F, mods: Command|Control, action: ToggleFullscreen }
|
||||||
|
|
||||||
- { key: Paste, action: Paste }
|
#- { key: Paste, action: Paste }
|
||||||
- { key: Copy, action: Copy }
|
#- { key: Copy, action: Copy }
|
||||||
- { key: L, mods: Control, action: ClearLogNotice }
|
#- { key: L, mods: Control, action: ClearLogNotice }
|
||||||
- { key: L, mods: Control, chars: "\x0c" }
|
#- { key: L, mods: Control, chars: "\x0c" }
|
||||||
- { key: PageUp, mods: Shift, action: ScrollPageUp, mode: ~Alt }
|
#- { key: PageUp, mods: Shift, action: ScrollPageUp, mode: ~Alt }
|
||||||
- { key: PageDown, mods: Shift, action: ScrollPageDown, mode: ~Alt }
|
#- { key: PageDown, mods: Shift, action: ScrollPageDown, mode: ~Alt }
|
||||||
- { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt }
|
#- { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt }
|
||||||
- { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt }
|
#- { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt }
|
||||||
|
|
|
@ -12,9 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::cmp::max;
|
use std::cmp::max;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use clap::{crate_authors, crate_description, crate_name, crate_version, App, Arg};
|
use clap::{crate_authors, crate_description, crate_name, crate_version, App, Arg};
|
||||||
use log::{self, LevelFilter};
|
use log::{self, LevelFilter};
|
||||||
|
@ -242,8 +241,8 @@ impl Options {
|
||||||
options
|
options
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn config_path(&self) -> Option<Cow<'_, Path>> {
|
pub fn config_path(&self) -> Option<PathBuf> {
|
||||||
self.config.as_ref().map(|p| Cow::Borrowed(p.as_path()))
|
self.config.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn into_config(self, mut config: Config) -> Config {
|
pub fn into_config(self, mut config: Config) -> Config {
|
||||||
|
@ -284,15 +283,12 @@ impl Options {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use alacritty_terminal::config::DEFAULT_ALACRITTY_CONFIG;
|
|
||||||
|
|
||||||
use crate::cli::Options;
|
use crate::cli::Options;
|
||||||
use crate::config::Config;
|
use crate::config::Config;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dynamic_title_ignoring_options_by_default() {
|
fn dynamic_title_ignoring_options_by_default() {
|
||||||
let config: Config =
|
let config = Config::default();
|
||||||
::serde_yaml::from_str(DEFAULT_ALACRITTY_CONFIG).expect("deserialize config");
|
|
||||||
let old_dynamic_title = config.dynamic_title();
|
let old_dynamic_title = config.dynamic_title();
|
||||||
|
|
||||||
let config = Options::default().into_config(config);
|
let config = Options::default().into_config(config);
|
||||||
|
@ -302,8 +298,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dynamic_title_overridden_by_options() {
|
fn dynamic_title_overridden_by_options() {
|
||||||
let config: Config =
|
let config = Config::default();
|
||||||
::serde_yaml::from_str(DEFAULT_ALACRITTY_CONFIG).expect("deserialize config");
|
|
||||||
|
|
||||||
let mut options = Options::default();
|
let mut options = Options::default();
|
||||||
options.title = Some("foo".to_owned());
|
options.title = Some("foo".to_owned());
|
||||||
|
@ -314,8 +309,7 @@ mod test {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dynamic_title_overridden_by_config() {
|
fn dynamic_title_overridden_by_config() {
|
||||||
let mut config: Config =
|
let mut config = Config::default();
|
||||||
::serde_yaml::from_str(DEFAULT_ALACRITTY_CONFIG).expect("deserialize config");
|
|
||||||
|
|
||||||
config.window.title = Some("foo".to_owned());
|
config.window.title = Some("foo".to_owned());
|
||||||
let config = Options::default().into_config(config);
|
let config = Options::default().into_config(config);
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs::File;
|
use std::io;
|
||||||
use std::io::{self, Read, Write};
|
use std::path::PathBuf;
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use dirs;
|
use dirs;
|
||||||
|
@ -11,15 +9,11 @@ use serde_yaml;
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
use xdg;
|
use xdg;
|
||||||
|
|
||||||
use alacritty_terminal::config::{
|
use alacritty_terminal::config::{Config as TermConfig, LOG_TARGET_CONFIG};
|
||||||
Config as TermConfig, DEFAULT_ALACRITTY_CONFIG, LOG_TARGET_CONFIG,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod bindings;
|
mod bindings;
|
||||||
pub mod monitor;
|
pub mod monitor;
|
||||||
mod mouse;
|
mod mouse;
|
||||||
#[cfg(test)]
|
|
||||||
mod test;
|
|
||||||
mod ui_config;
|
mod ui_config;
|
||||||
|
|
||||||
pub use crate::config::bindings::{Action, Binding, Key, RelaxedEq};
|
pub use crate::config::bindings::{Action, Binding, Key, RelaxedEq};
|
||||||
|
@ -48,7 +42,7 @@ pub enum Error {
|
||||||
Yaml(serde_yaml::Error),
|
Yaml(serde_yaml::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::error::Error for Error {
|
impl std::error::Error for Error {
|
||||||
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
|
fn cause(&self) -> Option<&dyn (::std::error::Error)> {
|
||||||
match *self {
|
match *self {
|
||||||
Error::NotFound => None,
|
Error::NotFound => None,
|
||||||
|
@ -68,7 +62,7 @@ impl ::std::error::Error for Error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::std::fmt::Display for Error {
|
impl std::fmt::Display for Error {
|
||||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
Error::NotFound => write!(f, "{}", ::std::error::Error::description(self)),
|
Error::NotFound => write!(f, "{}", ::std::error::Error::description(self)),
|
||||||
|
@ -111,7 +105,7 @@ impl From<serde_yaml::Error> for Error {
|
||||||
/// 3. $HOME/.config/alacritty/alacritty.yml
|
/// 3. $HOME/.config/alacritty/alacritty.yml
|
||||||
/// 4. $HOME/.alacritty.yml
|
/// 4. $HOME/.alacritty.yml
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
pub fn installed_config<'a>() -> Option<Cow<'a, Path>> {
|
pub fn installed_config() -> Option<PathBuf> {
|
||||||
// Try using XDG location by default
|
// Try using XDG location by default
|
||||||
xdg::BaseDirectories::with_prefix("alacritty")
|
xdg::BaseDirectories::with_prefix("alacritty")
|
||||||
.ok()
|
.ok()
|
||||||
|
@ -136,41 +130,11 @@ pub fn installed_config<'a>() -> Option<Cow<'a, Path>> {
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
})
|
})
|
||||||
.map(Into::into)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub fn installed_config<'a>() -> Option<Cow<'a, Path>> {
|
pub fn installed_config() -> Option<PathBuf> {
|
||||||
dirs::config_dir()
|
dirs::config_dir().map(|path| path.join("alacritty\\alacritty.yml")).filter(|new| new.exists())
|
||||||
.map(|path| path.join("alacritty\\alacritty.yml"))
|
|
||||||
.filter(|new| new.exists())
|
|
||||||
.map(Cow::from)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(windows))]
|
|
||||||
pub fn write_defaults() -> io::Result<Cow<'static, Path>> {
|
|
||||||
let path = xdg::BaseDirectories::with_prefix("alacritty")
|
|
||||||
.map_err(|err| io::Error::new(io::ErrorKind::NotFound, err.to_string().as_str()))
|
|
||||||
.and_then(|p| p.place_config_file("alacritty.yml"))?;
|
|
||||||
|
|
||||||
File::create(&path)?.write_all(DEFAULT_ALACRITTY_CONFIG.as_bytes())?;
|
|
||||||
|
|
||||||
Ok(path.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(windows)]
|
|
||||||
pub fn write_defaults() -> io::Result<Cow<'static, Path>> {
|
|
||||||
let mut path = dirs::config_dir().ok_or_else(|| {
|
|
||||||
io::Error::new(io::ErrorKind::NotFound, "Couldn't find profile directory")
|
|
||||||
})?;
|
|
||||||
|
|
||||||
path = path.join("alacritty/alacritty.yml");
|
|
||||||
|
|
||||||
std::fs::create_dir_all(path.parent().unwrap())?;
|
|
||||||
|
|
||||||
File::create(&path)?.write_all(DEFAULT_ALACRITTY_CONFIG.as_bytes())?;
|
|
||||||
|
|
||||||
Ok(path.into())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_from(path: PathBuf) -> Config {
|
pub fn load_from(path: PathBuf) -> Config {
|
||||||
|
@ -190,24 +154,31 @@ pub fn reload_from(path: &PathBuf) -> Result<Config> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_config(path: &PathBuf) -> Result<Config> {
|
fn read_config(path: &PathBuf) -> Result<Config> {
|
||||||
let mut contents = String::new();
|
let mut contents = std::fs::read_to_string(path)?;
|
||||||
File::open(path)?.read_to_string(&mut contents)?;
|
|
||||||
|
|
||||||
// Remove UTF-8 BOM
|
// Remove UTF-8 BOM
|
||||||
if contents.chars().nth(0) == Some('\u{FEFF}') {
|
if contents.chars().nth(0) == Some('\u{FEFF}') {
|
||||||
contents = contents.split_off(3);
|
contents = contents.split_off(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent parsing error with empty string
|
parse_config(&contents)
|
||||||
if contents.is_empty() {
|
}
|
||||||
return Ok(Config::default());
|
|
||||||
|
fn parse_config(contents: &str) -> Result<Config> {
|
||||||
|
match serde_yaml::from_str(&contents) {
|
||||||
|
Err(error) => {
|
||||||
|
// Prevent parsing error with an empty string and commented out file.
|
||||||
|
if std::error::Error::description(&error) == "EOF while parsing a value" {
|
||||||
|
Ok(Config::default())
|
||||||
|
} else {
|
||||||
|
Err(Error::Yaml(error))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Ok(config) => {
|
||||||
|
print_deprecation_warnings(&config);
|
||||||
|
Ok(config)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
let config = serde_yaml::from_str(&contents)?;
|
|
||||||
|
|
||||||
print_deprecation_warnings(&config);
|
|
||||||
|
|
||||||
Ok(config)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_deprecation_warnings(config: &Config) {
|
fn print_deprecation_warnings(config: &Config) {
|
||||||
|
@ -232,3 +203,16 @@ fn print_deprecation_warnings(config: &Config) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
static DEFAULT_ALACRITTY_CONFIG: &str =
|
||||||
|
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../alacritty.yml"));
|
||||||
|
|
||||||
|
use super::Config;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn config_read_eof() {
|
||||||
|
assert_eq!(super::parse_config(DEFAULT_ALACRITTY_CONFIG).unwrap(), Config::default());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
use alacritty_terminal::config::DEFAULT_ALACRITTY_CONFIG;
|
|
||||||
|
|
||||||
use crate::config::Config;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn parse_config() {
|
|
||||||
let config: Config =
|
|
||||||
::serde_yaml::from_str(DEFAULT_ALACRITTY_CONFIG).expect("deserialize config");
|
|
||||||
|
|
||||||
// Sanity check that mouse bindings are being parsed
|
|
||||||
assert!(!config.ui_config.mouse_bindings.is_empty());
|
|
||||||
|
|
||||||
// Sanity check that key bindings are being parsed
|
|
||||||
assert!(!config.ui_config.key_bindings.is_empty());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn default_match_empty() {
|
|
||||||
let default = Config::default();
|
|
||||||
|
|
||||||
let empty = serde_yaml::from_str("key: val\n").unwrap();
|
|
||||||
|
|
||||||
assert_eq!(default, empty);
|
|
||||||
}
|
|
|
@ -19,6 +19,16 @@ pub struct UIConfig {
|
||||||
pub mouse_bindings: Vec<MouseBinding>,
|
pub mouse_bindings: Vec<MouseBinding>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for UIConfig {
|
||||||
|
fn default() -> Self {
|
||||||
|
UIConfig {
|
||||||
|
mouse: Mouse::default(),
|
||||||
|
key_bindings: default_key_bindings(),
|
||||||
|
mouse_bindings: default_mouse_bindings(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn default_key_bindings() -> Vec<KeyBinding> {
|
fn default_key_bindings() -> Vec<KeyBinding> {
|
||||||
bindings::default_key_bindings()
|
bindings::default_key_bindings()
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ use std::sync::Arc;
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use dirs;
|
use dirs;
|
||||||
use glutin::event_loop::EventLoop as GlutinEventLoop;
|
use glutin::event_loop::EventLoop as GlutinEventLoop;
|
||||||
use log::{error, info};
|
use log::info;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use winapi::um::wincon::{AttachConsole, FreeConsole, ATTACH_PARENT_PROCESS};
|
use winapi::um::wincon::{AttachConsole, FreeConsole, ATTACH_PARENT_PROCESS};
|
||||||
|
|
||||||
|
@ -85,18 +85,8 @@ fn main() {
|
||||||
.expect("Unable to initialize logger");
|
.expect("Unable to initialize logger");
|
||||||
|
|
||||||
// Load configuration file
|
// Load configuration file
|
||||||
// If the file is a command line argument, we won't write a generated default file
|
let config_path = options.config_path().or_else(config::installed_config);
|
||||||
let config_path = options
|
let config = config_path.map(config::load_from).unwrap_or_else(Config::default);
|
||||||
.config_path()
|
|
||||||
.or_else(config::installed_config)
|
|
||||||
.or_else(|| config::write_defaults().ok())
|
|
||||||
.map(|path| path.to_path_buf());
|
|
||||||
let config = if let Some(path) = config_path {
|
|
||||||
config::load_from(path)
|
|
||||||
} else {
|
|
||||||
error!("Unable to write the default config");
|
|
||||||
Config::default()
|
|
||||||
};
|
|
||||||
let config = options.into_config(config);
|
let config = options.into_config(config);
|
||||||
|
|
||||||
// Update the log level from config
|
// Update the log level from config
|
||||||
|
|
|
@ -18,7 +18,6 @@ use std::fmt::Display;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use log::error;
|
use log::error;
|
||||||
use serde::de::DeserializeOwned;
|
|
||||||
use serde::{Deserialize, Deserializer};
|
use serde::{Deserialize, Deserializer};
|
||||||
use serde_yaml::Value;
|
use serde_yaml::Value;
|
||||||
|
|
||||||
|
@ -39,15 +38,13 @@ pub use crate::config::visual_bell::{VisualBellAnimation, VisualBellConfig};
|
||||||
pub use crate::config::window::{Decorations, Dimensions, StartupMode, WindowConfig, DEFAULT_NAME};
|
pub use crate::config::window::{Decorations, Dimensions, StartupMode, WindowConfig, DEFAULT_NAME};
|
||||||
use crate::term::color::Rgb;
|
use crate::term::color::Rgb;
|
||||||
|
|
||||||
pub static DEFAULT_ALACRITTY_CONFIG: &str =
|
|
||||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../alacritty.yml"));
|
|
||||||
pub const LOG_TARGET_CONFIG: &str = "alacritty_config";
|
pub const LOG_TARGET_CONFIG: &str = "alacritty_config";
|
||||||
const MAX_SCROLLBACK_LINES: u32 = 100_000;
|
const MAX_SCROLLBACK_LINES: u32 = 100_000;
|
||||||
|
|
||||||
pub type MockConfig = Config<HashMap<String, serde_yaml::Value>>;
|
pub type MockConfig = Config<HashMap<String, serde_yaml::Value>>;
|
||||||
|
|
||||||
/// Top-level config type
|
/// Top-level config type
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Default, Deserialize)]
|
||||||
pub struct Config<T> {
|
pub struct Config<T> {
|
||||||
/// Pixel padding
|
/// Pixel padding
|
||||||
#[serde(default, deserialize_with = "failure_default")]
|
#[serde(default, deserialize_with = "failure_default")]
|
||||||
|
@ -142,12 +139,6 @@ pub struct Config<T> {
|
||||||
pub persistent_logging: Option<bool>,
|
pub persistent_logging: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DeserializeOwned> Default for Config<T> {
|
|
||||||
fn default() -> Self {
|
|
||||||
serde_yaml::from_str(DEFAULT_ALACRITTY_CONFIG).expect("default config is invalid")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Config<T> {
|
impl<T> Config<T> {
|
||||||
pub fn tabspaces(&self) -> usize {
|
pub fn tabspaces(&self) -> usize {
|
||||||
self.tabspaces.0
|
self.tabspaces.0
|
||||||
|
|
Loading…
Reference in a new issue