-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
166 lines (144 loc) · 5.39 KB
/
.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Aliases for the current shell
# Source them in the shell config
# Filesystem Manipulation
# =======================
alias ls='ls -F --color=auto'
alias la='ls -AFh --color=auto'
alias ll='ls -AFhl --color=auto'
alias cp='cp -rvi'
alias mv='mv -vi'
alias disks='lsblk | grep -v loop'
# check for disk usage according to partitions (diskfree)
# print first line of df unaffected, then sorts by most 'Usage' field
alias diskf='echo -e "$(df -h | head -1)" && df -h | tail +2 | grep -v loop | sort -hrk3'
# Neovim Configurations
# =====================
alias lzvim="NVIM_APPNAME=lazyvim nvim"
alias kvim="NVIM_APPNAME=kickstart.nvim nvim"
alias nvchad="NVIM_APPNAME=nvchad nvim"
alias avim="NVIM_APPNAME=astronvim nvim"
# Utilities
# =========
alias refish='source ~/.config/fish/config.fish'
alias rezsh='source ~/.zshrc'
alias rebash='source ~/.bashrc'
alias py='python3'
alias x='eza --icons'
alias xa='eza -larsmod --icons --git'
alias trees='tree -ahF -t --du --filesfirst -C | less -R'
alias hypstat='hyperfine -N --warmup 5'
alias info='info --vi-keys'
# always inform if files are identical
alias diff='diff -su --color'
alias journalfzf='journalctl | fzf --preview "echo {6..}" --preview-window="bottom:4:wrap"'
# use default fzf opts and fallbacks for handling different sorts of previews
# try to preview file with bat; if fails try to list directory with eza; else
# output formatted text
alias fzf='fzf --preview "bat --style=numbers --color=always --line-range :500 {} 2>/dev/null || eza --color=always --icons {} 2>/dev/null || echo {}"'
# System Processes
# get proc info from pid
alias pinfo='ps -fp'
# find a proc by name and output information
alias pfind='pgrep -a'
# find which program is using a resource
alias puser='fuser -uv'
# fuzzy find processes
# ** moved to scripts directory .bin/psfzf **
# Package Manager
# ===============
alias pacupd='sudo pacman -Syu --noconfirm'
alias pacups='checkupdates --nocolor | fzf --preview "pacman -Qii {1}"'
alias pacfzf='pacman -Q --color=always | fzf --ansi --preview "pacman -Qii {1}" | cut -f1 -d " "'
alias pacache='du -sh /var/cache/pacman/pkg'
alias mirrors='sudo reflector --verbose --sort rate --country India --latest 5 --save /etc/pacman.d/mirrorlist'
# remove redundant entries (multiple /usr/bin or /usr/share/ duplicates)
alias pacfiles='pacman -Ql | sort -k2 | uniq -f1 | fzf --preview "bat --color=always {2} 2>/dev/null || eza --icons {2}"'
alias paclog='paclog --color | less -R'
alias paclogs='tac /var/log/pacman.log | fzf --preview "echo {3..}" --preview-window="bottom:5:wrap"'
# requires pacutils package
alias cpaclogs='paclog --color | tac | fzf --preview "echo {3..}" --preview-window="bottom:5:wrap" --ansi'
# CP or Leetcode
# ==============
alias gs++='g++ -Wall -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer'
alias gdl='g++ -g leetcode.cpp && gdb -q ./a.out --tui'
# use cgdb as gdb frontend
alias cgdl='g++ -g leetcode.cpp && cgdb -q ./a.out'
# mneumonic for (g)cc (c)ompile (lc) leetcode (ch) codechef
alias gclc='g++ leetcode.cpp && ./a.out'
alias gcch='g++ codechef.cpp && ./a.out <inp.out | cat -A'
# start a counter for a problem, provide file argument as an alarm
alias startcount='termdown 20m --title "Problem" && mpv'
# Vim aliases
# ===========
# -S are for loading the session files (Session.vim)
alias v='vim'
alias vs='vim -S'
alias vrc='vim ~/.vimrc'
alias nvs='nvim -S'
alias lrc='lvim ~/.config/lvim/config.lua'
alias nvrc='nvim ~/.config/nvim/init.lua'
# fuzzy find and open a file in vim
alias vfzf='fzf --height 80% --preview "bat --style=numbers --color=always --line-range :500 {}" | xargs -ro vim'
# tmux Aliases
# ============
# -t refers to target session
alias tmas='tmux attach-session -t'
alias tmks='tmux kill-session -t'
alias tmns='tmux new-session -t'
alias tmls='tmux ls'
# Git Aliases
# ===========
# one-off aliases
alias gits='git status'
alias gitf='git fetch'
alias gitp='git pull'
alias gitP='git push'
alias gitb='git branch'
alias gitsw='git switch'
alias gitss='git show --stat -p'
alias gitrs='git restore --staged'
alias gitun='git reset --soft HEAD~'
alias gitchose='git checkout $(gitfzf)'
alias lg='lazygit'
# show the number of commits
alias gitcount='git rev-list --count HEAD'
# CHECKOUT
# ========
alias gitch='git checkout'
# checkout parts of a file (maybe from a specific commit)
# git checkout -p <sha>^ -- <file>
alias gitchp='git checkout -p'
# DIFF
# ====
alias gitd='git diff --stat -p'
alias gitds='git diff --stat --staged -p'
# ADD
# ===
alias gita='git add'
# stage parts of a file
alias gitap='git add -p'
alias gitA='git add -A'
alias gitac='git add -A && git commit'
# COMMIT
# ======
alias gitc='git commit'
alias gitcp='git commit && git push'
alias gitu='git add . && git commit && git push'
# LOG
# ===
alias gitl='git log --stat --graph --color | less'
# track a file changes accross commits
alias gitlf='git log --follow --stat -p --'
# find a commit by message,
# add --all at end to search all branches, -i for ignorecase
alias gitlg='git log --stat --grep'
# fuzzy search for a commit in git
# ** moved to scripts directory .bin/gitfzf **
# STASH
# =====
alias gitstl='git stash list'
alias gitstp='git stash pop'
# show stashed changes, accepts stash index
alias gitsts='git stash show -p --stat'
# save the work in progress in a named stash
alias gitsave='git stash push -um'