summaryrefslogtreecommitdiff
path: root/shells/README.org
blob: 7b5f8eda7434cb28301f49567d04fbf1b00c4f67 (plain)
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
#+TITLE: My Shells Configs
#+AUTHOR: Naz <ndpm13@ch-naseem.com>
#+STARTUP: showeverything
#+OPTIONS: toc:nil
#+PROPERTY: header-args :mkdirp yes
#+auto_tangle: t

* Table Of Content :toc:
- [[#aliases][Aliases]]
  - [[#basic][Basic]]
  - [[#package-managers][Package Managers]]
  - [[#youtube][YouTube]]
  - [[#use-doas][Use doas]]
  - [[#all-aliases][All Aliases]]
- [[#functions][Functions]]
  - [[#lf-navigation][LF Navigation]]
  - [[#make--cd-to-directory][Make & CD to Directory]]
  - [[#all-functions][All Functions]]
- [[#prompt][Prompt]]
  - [[#zsh][ZSH]]
  - [[#bash][Bash]]
- [[#configuration][Configuration]]
  - [[#history-settings][History Settings]]
  - [[#shell-specific][Shell Specific]]
  - [[#shell-rc-files][Shell RC Files]]

* Aliases

This is a collection of aliases to make the shell usable, for those who can't
type 99999 WPM.

#+NAME: source-aliases
#+begin_src sh
source $HOME/.config/shells/aliases
#+end_src

** Basic

Starting off with some colors! Some of these aliases depend on some Rust /based/
CLIs (~zoxide~, ~eza~).

#+NAME: basic-aliases
#+begin_src sh
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='rm -vI'
alias cd='z'
alias ls='eza --icons=always --group-directories-first'
alias ll='ls -la --git'
alias dir='ll ./*'
alias tree='ls -Ta -I ".git|target"'
alias cls='clear'
alias v='nvim'
alias rv='command sudo -E nvim'
alias code='codium'
alias dl='wget -cq --show-progress'
alias ip='ip -c'
alias ping='ping -c 3'
alias py='python'
#+end_src

** Package Managers

*** XBPS

No need for any of these, just use [[https://git.ch-naseem.com/noid-linux/ndpm][ndpm]] instead.

#+NAME: xbps-aliases
#+begin_src sh
alias xi='doas xbps-install -S'
alias xq='doas xbps-query -Rs'
alias xr='doas xbps-remove -R'
alias xo='xr -Oo'
alias xu='xi && doas xbps-install -uy xbps && doas xbps-install -uy && xo && pkill -RTMIN+14 dwmblocks'
alias xf="xq '' | cut -d' ' -f2 | fzf --multi --preview 'xbps-query -R {1}' --preview-window=down:75% | xargs -ro xi"
#+end_src

*** Cargo

The name of the package is ~cargo-update~, you are welcome.

#+NAME: cargo-aliases
#+begin_src sh
alias cargo-update='cargo install-update -a'
#+end_src

*** Python

💩

#+NAME: pip-aliases
#+begin_src sh
alias pip-update='pip install --upgrade pip'
#+end_src

** YouTube

For these you'll need ~mpv~ obviously but also ~yt-dlp~. YouTube is bloated AF
and Invidious is getting canceled, so get advantage of these and consume your
brainrot in peace.

#+NAME: youtube-aliases
#+begin_src sh
alias yt480="mpv --save-position-on-quit '--ytdl-format=bv*[height<=480]+ba'"
alias yt720="mpv --save-position-on-quit '--ytdl-format=bv*[height<=720]+ba'"
alias yt1080="mpv --save-position-on-quit '--ytdl-format=bv*[height<=1080]+ba'"
#+end_src

** Use doas

YOU SHOULD NOT USE SUDO BECAUSE IT'S BLOATED AND DOESN'T FOLLOW UNIX PHILOSOPHY
THUS IT'S EVIL AND INVADES YOUR PRIVACY AND USED BY BIG TECH TO BRAIN WASH YOUR
BRAIN!!!

#+NAME: sudo-alias
#+begin_src sh
alias sudo='echo "use doas idiot" ||'
#+end_src

** All Aliases

#+NAME: all-aliases
#+begin_src sh :tangle .config/shells/aliases :noweb yes
# Basic Aliases
<<basic-aliases>>

# XBPS Aliases
<<xbps-aliases>>

# Cargo Aliases
<<cargo-aliases>>

# Python Aliases
<<python-aliases>>

# YouTube Aliases
<<youtube-aliases>>

# Use doas
<<sudo-alias>>
#+end_src

* Functions

I'll probably convert these into small shell scripts and remove this block, for
now tho they're staying here.

#+NAME: source-functions
#+begin_src sh
source $HOME/.config/shells/functions
#+end_src

** LF Navigation

No idea what this is for, I copied it from [[https://github.com/gokcehan/lf/blob/master/etc/lfcd.sh][here]].

#+NAME: lf-functions
#+begin_src sh
LFCD="$HOME/.local/bin/lfcd"
if [ -f "$LFCD" ]; then
    source "$LFCD"
fi
#+end_src

** Make & CD to Directory

...need I say more?

#+NAME: md-function
#+begin_src sh
function md { mkdir -pv "$1" && cd "$1"; }
#+end_src

** All Functions

#+NAME: all-functions
#+begin_src sh :tangle .config/shells/functions :noweb yes
# LF Functions
<<lf-functions>>

# MD Function
<<md-function>>
#+end_src

* Prompt

A great person once said:

#+begin_quote
A beautiful prompt improves the productivity and efficiency of developers. The
more colors and nerd icons you add the greater your productivity gets.
#+end_quote

** ZSH

*** Simple

#+NAME: zsh-simple-prompt
#+begin_src sh
PROMPT=" %F{7}%~%f %B$ "
#+end_src

*** Starship

#+NAME: zsh-starship-prompt
#+begin_src sh
eval "$(starship init zsh)"
#+end_src

*** Oh My Posh

#+NAME: zsh-omp-prompt
#+begin_src sh
eval "$(oh-my-posh init zsh --config $HOME/.config/ohmyposh/config.toml)"
#+end_src

** Bash

*** Simple

#+NAME: bash-simple-prompt
#+begin_src sh
PS1='\[\e[91;1m\][\[\e[93m\]\u\[\e[92m\]@\[\e[94m\]\h \[\e[0;95m\]\W\[\e[91;1m\]]\[\e[0m\]\\$ '
#+end_src

*** Starship

#+NAME: bash-starship-prompt
#+begin_src sh
eval "$(starship init bash)"
#+end_src

* Configuration

** History Settings

#+NAME: config-history
#+begin_src sh
HISTFILE=$HOME/.config/shells/history
HISTSIZE=50000
SAVEHIST=50000
#+end_src

** Shell Specific

*** ZSH

**** Syntax highlighting

For this you'll need to install a package named ~zsh-syntax-highlighting~ in the
xbps repositories, look it up if you are not a Void user.

#+NAME: zsh-syntax-highlighting
#+begin_src zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
#+end_src

**** Colors settings

#+NAME: zsh-colors
#+begin_src zsh
autoload -U colors && colors
#+end_src

**** Completion

As before the package's name in the xbps repos is ~zsh-completions~.

#+NAME: zsh-completion
#+begin_src zsh
autoload -U compinit
zstyle ':completion:*' menu select
zmodload zsh/complist
compinit
_comp_options+=(globdots)
#+end_src

Use vi bindings in tab complete menu.

#+NAME: zsh-completion-vi
#+begin_src zsh
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
bindkey -v '^?' backward-delete-char
#+end_src

**** Vi mode

#+NAME: zsh-vi
#+begin_src zsh
bindkey -v
#+end_src

**** Key bindings

#+NAME: zsh-key-bindings
#+begin_src zsh
bindkey -s '^o' 'lf\n'
bindkey -s '^v' 'v\n'
#+end_src

**** Fix cursor

When using the underscore ~_~ character as the terminal's cursor, Neovim might
override it with the ugly block cursor. Using this mess down here you can stop
that.

#+NAME: zsh-nvim-cursor
#+begin_src zsh
zle-line-init() {
    echo -e -n "\x1b[\x34 q"
}
zle -N zle-line-init
echo -e -n "\x1b[\x34 q"
preexec() { echo -e -n "\x1b[\x34 q" ;}
#+end_src

**** Evals

***** Zoxide

#+NAME: zsh-eval-zoxide
#+begin_src zsh
eval "$(zoxide init zsh)"
#+end_src

***** Fzf

#+NAME: zsh-eval-fzf
#+begin_src zsh
source <(fzf --zsh)
#+end_src

*** bash

**** Completion

Just like with ZSH completions you'll need to install a package named
~bash-completion~ in the xbps repos.

#+NAME: bash-completion
#+begin_src bash
[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && \
    . /usr/share/bash-completion/bash_completion
#+end_src

**** Vi mode

#+NAME: bash-vi
#+begin_src bash
set -o vi
#+end_src

**** Evals

***** Zoxide

#+NAME: bash-eval-zoxide
#+begin_src bash
eval "$(zoxide init bash)"
#+end_src

***** Fzf

#+NAME: bash-eval-fzf
#+begin_src bash
eval "$(fzf --bash)"
#+end_src

** Shell RC Files

*** Common

#+NAME: source-shellsrc
#+begin_src sh
source $HOME/.config/shells/shellsrc
#+end_src

**** SHELLSRC

#+NAME: shellsrc
#+begin_src sh :tangle .config/shells/shellsrc :noweb yes
# History settings
<<config-history>>

# Aliases
<<source-aliases>>

# Functions
<<source-functions>>
#+end_src

*** ZSH

#+NAME: dotzshrc
#+begin_src zsh :tangle .zshrc
source $HOME/.config/zsh/zshrc
#+end_src

**** ZSHRC

#+NAME: zshrc
#+begin_src zsh :tangle .config/zsh/zshrc :noweb yes
# Common configs
<<source-shellsrc>>

# Syntax highlighting
<<zsh-syntax-highlighting>>

# Colors settings
<<zsh-colors>>

# Completion
<<zsh-completion>>

<<zsh-completion-vi>>

# Vi mode
<<zsh-vi>>

# Key bindings
<<zsh-key-bindings>>

# Fix Cursor Shape After Using Neovim
<<zsh-nvim-cursor>>

# Eval Zoxide
<<zsh-eval-zoxide>>

# Eval FZF
<<zsh-eval-fzf>>

# Prompt
<<zsh-starship-prompt>>
#+end_src

*** Bash

#+NAME: dotbashrc
#+begin_src bash :tangle .bashrc
source $HOME/.config/bash/bashrc
#+end_src

**** BASHRC

#+NAME: bashrc
#+begin_src bash :tangle .config/bash/bashrc :noweb yes
# Common configs
<<source-shellsrc>>

# Completion
<<bash-completion>>

# Vi mode
<<bash-vi>>

# Eval Zoxide
<<bash-eval-zoxide>>

# Eval FZF
<<bash-eval-fzf>>

# Prompt
<<bash-simple-prompt>>
#+end_src