-
-
Save ales-tsurko/cc8cb59f6d5a1aa95512e81e3dfe64ff to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| # This installs alacritty terminal on ubuntu (https://github.com/jwilm/alacritty) | |
| # You have to have rust/cargo installed for this to work | |
| # Install required tools | |
| sudo apt-get install -y cmake libfreetype6-dev libfontconfig1-dev xclip | |
| # Download, compile and install Alacritty | |
| git clone https://github.com/jwilm/alacritty | |
| cd alacritty | |
| cargo build --release | |
| # Add Man-Page entries | |
| sudo mkdir -p /usr/local/share/man/man1 | |
| gzip -c extra/alacritty.man | sudo tee /usr/local/share/man/man1/alacritty.1.gz > /dev/null | |
| # Add shell completion for bash and zsh | |
| mkdir -p ~/.bash_completion | |
| cp extra/completions/alacritty.bash ~/.bash_completion/alacritty | |
| echo "source ~/.bash_completion/alacritty" >> ~/.bashrc | |
| sudo mkdir -p /usr/share/zsh/functions/Completion/X/ | |
| sudo cp extra/completions/_alacritty /usr/share/zsh/functions/Completion/X/_alacritty | |
| # Copy default config into home dir | |
| cp alacritty.yml ~/.alacritty.yml | |
| # Create desktop file | |
| mkdir -p ~/.local/share/applications/ | |
| cp extra/linux/Alacritty.desktop ~/.local/share/applications/ | |
| # Copy binary to path | |
| sudo cp target/release/alacritty /usr/local/bin | |
| # Remove temporary dir | |
| cd .. | |
| rm -rf alacritty |
On Ubuntu need also :
$ sudo apt install libxcb-composite0-dev libx11-xcb-dev
Some improvements:
# Add shell completion for bash (system-wide)
sudo mkdir -p /usr/local/share/bash-completion/completions/
sudo cp extra/completions/alacritty.bash /usr/local/share/bash-completion/completions/alacritty
# Add shell completion for fish
sudo mkdir -p /usr/local/fish/completions/
sudo cp extra/completions/alacritty.fish /usr/local/fish/completions/
# Add desktop file (system-wide)
sudo mkdir -p /usr/local/share/applications/
sudo cp extra/linux/Alacritty.desktop /usr/local/share/applications/
# Add icons
sudo mkdir -p /usr/local/share/icons/hicolor/{scalable,symbolic}/apps/
sudo cp extra/logo/alacritty-term.svg /usr/local/share/icons/hicolor/scalable/apps/Alacritty.svg
sudo cp extra/logo/alacritty-simple.svg /usr/local/share/icons/hicolor/symbolic/apps/Alacritty-symbolic.svgInstead of cargo install --path alacritty/ I suggest using cargo build --release. The former automatically installs the binary to ~/.cargo/bin/alacritty.
On Ubuntu 18.04 I also had to apt install libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev.
Also, if you're installing this for just your user in ~/.local/share/ instead of /usr/share/ I had to make a few edits to the .desktop file. I had to remove the the TryExec (although changing it to an absolute path might also work) and I had to change the Exec values to the absolute path to ~/.local/bin/alacritty instead of just alacritty.
Another useful thing you can do is make Alacritty available as your default terminal:
$ sudo update-alternatives --install $(which x-terminal-emulator) x-terminal-emulator $(which alacritty) 40
$ sudo update-alternatives --config x-terminal-emulator
The second command should present you with a list of terminals you have available for your default terminal. Just select Alacritty and it should open as your default terminal.
Instead of cargo install --path alacritty/ I suggest using cargo build --release. The former automatically installs the binary to ~/.cargo/bin/alacritty.
This is surprising... cargo build --release usually just normal cargo build command but for release target (i.e. with optimizations). So it should put the build artifacts inside target at the source root or $CARGO_TARGET_DIR if it's specified. Are you sure in this?
UPD
Hmm But doing cargo install --path alacritty/ doesn't make sense as well, because at the end we copy the binary from target/releaseanyway (which is built by cargo build --release as a part of cargo install). Will update the script.
Thanks! Helped a lot.