-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.arch_aliases
152 lines (121 loc) · 3.95 KB
/
.arch_aliases
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#! /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/>.
# .arch_aliases: various aliases for Bash environments
# Equivalent to .bash_aliases
# General aliases
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias cdp='cd -P .' # Resolve symlinks in the current working path
alias cls='clear'
alias clsa='clear; lsa'
alias :q='exit'
alias su='sudo --login'
alias hg='history | grep'
alias relog='sudo login -p $(whoami); exit'
# Program-specific aliases
# Detect if a program or alias exists
has() {
[ "$(type "$1" 2> /dev/null)" ]
}
# Neovim
has nvim && alias nv="nvim"
# Eza
has eza && {
alias ls='eza --oneline --group-directories-first'
alias lsa='ls --long --all --header --smart-group --binary'
alias tree='ls --tree'
alias treea='lsa --tree'
# While respecting `.gitignore`, display the current directory as a tree, showing the Git status
# of each file
alias treeg='tree --long --git-ignore --git \
--no-permissions --no-filesize --no-user --no-time'
}
# sl
has sl && {
alias sl='sl -e'
has lsa && alias las='sl'
has clsa && {
alias csla='sl'
alias clas='sl'
}
}
# Batcat
has batcat && alias bat='batcat'
# Du/Dust
has du && alias dus='du --all --human-readable --max-depth=1 | sort --human-numeric-sort --reverse'
# Diffs
has diff && alias gdiff='diff --unified --color=auto' # Git-style
has nvim && alias ndiff='nvim -d' # With Neovim
# WSL
has wslview && alias wv='wslview'
has notepad.exe && alias np='notepad.exe'
has explorer.exe && {
alias ex='explorer.exe'
alias e.='explorer.exe .'
}
has clip.exe && alias cl='clip.exe'
# Text formatting
has fold && alias format='fold --spaces'
# Adds manpages for various Rust toolchain commands, or defaults to plain-old `man`.
has rustup && man() {
local IFS='-'
rustup man "$*"
}
# Joke alias for `cargo`.
#
# Use `carbo hydrate ...` instead of `cargo build ...`.
# Otherwise, just use `carbo ...` instead of `cargo ...`.
has cargo && carbo() {
local command="$1"
shift
[ "$command" = 'hydrate' ] && command='build'
cargo "$command" "$@"
}
# Debugging Rust test binaries.
has rust-gdb && has cargo && {
# Build in test mode, extract the binary from the output, and launch `rust-gdb` with it.
alias dbg-test='rust-gdb "$(cargo test --no-run 2>&1 >/dev/null | grep "Executable" | sed '"'"'s/.*(\(.*\))/\1/'"'"')"'
}
# Git
has git && alias git-graph='git log --graph --decorate --oneline --all'
# Run a binary downloaded by `mason.nvim`
[ -d "${XDG_DATA_HOME:-$HOME/.local/share}/nvim/mason/bin" ] && mason() {
local bin_dir="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/mason/bin"
local binary="$1"
shift # Clear out the target binary.
case "$binary" in
# List out the available binaries.
ls | list )
\ls -1 --almost-all "$bin_dir"
;;
# Run target binary with args.
* )
"$bin_dir/$binary" "$@"
;;
esac
}
# NPM
# Equivalent to `alias npr='npm run'`, except that `npr b` expands to `npm run build`.
has npm && npr() {
local command="$1"
shift
[ "$command" = 'b' ] && command='build'
npm run "$command" "$@"
}
# Typst
# Compile a Typst document.
has typst && typc() {
local file="$1"
typst compile "$file" "./out/$(basename "$file" '.typ').pdf"
}