-
Notifications
You must be signed in to change notification settings - Fork 0
/
.archrc
87 lines (67 loc) · 2.87 KB
/
.archrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#! /usr/bin/env bash
# SPDX-License-Identifier: GPL-3.0-or-later
#
# Copyright © 2024 RemasteredArch
#
# This file is part of dotfiles.
#
# Dotfiles is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# Dotfiles is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with dotfiles. If not, see <https://www.gnu.org/licenses/>.
# .archrc: .bashrc equivalent, named otherwise in order to preserve distro-specific configurations
# Install by adding `[ -f "path/to/this/file" ] && . "path/to/this/file"` to your .bashrc
source="${BASH_SOURCE[0]}"
source_dir="$(dirname "$source")"
dotfiles_dir=$(dirname "$(realpath "$source")")
# Detects if a program or alias exists
has() {
[ "$(type "$1" 2> /dev/null)" ]
}
# A dictionary of ANSI color escape codes
set_color() {
local color_name=$1
local ansi_control_code=$2
colors[$color_name]="\e[${ansi_control_code}m"
}
declare -A colors
set_color reset 0
set_color bold 1
set_color green 32
unset set_color
# Set default prompt
PS1="\[${colors[green]}\]\$ \u @ \H > \w > \[${colors[reset]}\]" # e.g. `$ arch @ PC > ~ > `
# Use starship for the prompt while in tmux
[ -n "$TMUX" ] && has starship && eval "$(starship init bash)"
# Case-insensive tab completion
bind 'set completion-ignore-case on'
# Stop ringing bells in the shell
bind 'set bell-style none'
# User-installed programs
user_bin_dir="$HOME/.local/bin"
[ -d "$user_bin_dir" ] || mkdir -p "$user_bin_dir"
export PATH="$user_bin_dir:$PATH"
unset user_bin_dir
# Enable various aliases
[ -f "$source_dir/.arch_aliases" ] && . "$source_dir/.arch_aliases"
# Set default text editor to Neovim
has nvim && export EDITOR="nvim" && export VISUAL="$EDITOR"
# Set XDG user directories
XDG_CONFIG_HOME="$HOME/.config"
[ -d "$XDG_CONFIG_HOME" ] || mkdir -p "$XDG_CONFIG_HOME"
export XDG_CONFIG_HOME
# GPG signing passphrase prompt
GPG_TTY=$(tty)
export GPG_TTY
# Manual formatting with bat
# Snippet by github.com/ValentinLeTallec
# https://github.com/sharkdp/bat/issues/2219#issuecomment-1645456156
export MANPAGER="sh -c 'sed -r \"s/\x1B\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]//g\" | batcat --language man --plain'"
# Provides various binary, decimal, and hexadecimal conversions
# shellcheck disable=SC1091
[ -f "$dotfiles_dir/scripts/dotfiles/number_conversion.sh" ] && . "$dotfiles_dir/scripts/dotfiles/number_conversion.sh"
# Shell completions for `cargo`
# shellcheck disable=SC1091
has rustc && . "$(rustc --print sysroot)/etc/bash_completion.d/cargo"
unset source source_dir dotfiles_dir colors