Update others
This commit is contained in:
@ -1,125 +1,23 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
# shellcheck disable=SC1090,SC1091,SC2034
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
# Required init for cli programs
|
source "$XDG_CONFIG_HOME/bash/.bash_aliases"
|
||||||
# Do not install completions unless no working, check /usr/share/bash-completion
|
|
||||||
|
|
||||||
# Local bash-completion
|
# If we have local bash-completion, use it
|
||||||
if [[ -f $HOME/.local/bin/bash_completion ]]; then
|
if [[ -f $HOME/.local/bin/bash_completion ]]; then
|
||||||
. $HOME/.local/bin/bash_completion
|
. "$HOME/.local/bin/bash_completion"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Rust
|
# If we have local rust installed, set it up
|
||||||
if [[ -f $HOME/.local/share/cargo/env ]]; then
|
if [[ -f $HOME/.local/share/cargo/env ]]; then
|
||||||
. $HOME/.local/share/cargo/env
|
. "$HOME/.local/share/cargo/env"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set aliases
|
# Bash XDG history
|
||||||
if hash rg 2>/dev/null; then
|
export HISTFILE="$XDG_STATE_HOME"/bash/history
|
||||||
alias grep="rg"
|
|
||||||
fi
|
|
||||||
if hash bat 2>/dev/null; then
|
|
||||||
alias cat="bat -p"
|
|
||||||
fi
|
|
||||||
if hash zoxide 2>/dev/null; then
|
|
||||||
alias cd="z"
|
|
||||||
fi
|
|
||||||
if hash fd 2>/dev/null;then
|
|
||||||
alias find="fd"
|
|
||||||
fi
|
|
||||||
if hash numbat 2>/dev/null; then
|
|
||||||
alias bc="numbat"
|
|
||||||
fi
|
|
||||||
#if hash sd 2>/dev/null; then
|
|
||||||
# alias sed="sd"
|
|
||||||
#fi
|
|
||||||
if hash dust 2>/dev/null; then
|
|
||||||
alias du="dust"
|
|
||||||
fi
|
|
||||||
if hash tealdeer 2>/dev/null; then
|
|
||||||
alias tldr="tealdeer"
|
|
||||||
fi
|
|
||||||
if hash hexyl 2>/dev/null; then
|
|
||||||
alias xxd="hexyl"
|
|
||||||
fi
|
|
||||||
if hash micro 2>/dev/null; then
|
|
||||||
alias edit="micro"
|
|
||||||
alias nano="micro"
|
|
||||||
fi
|
|
||||||
if hash xdg-open 2>/dev/null; then
|
|
||||||
alias start="xdg-open"
|
|
||||||
fi
|
|
||||||
alias update="eget -D; . $HOME/.config/eget/post_install.sh"
|
|
||||||
alias rc="source ~/.bashrc"
|
|
||||||
alias nix-shell-local="nix-user-chroot ~/.local/share/nix bash"
|
|
||||||
if [ -e ~/.nix-profile/etc/profile.d/nix.sh ]; then
|
|
||||||
. ~/.nix-profile/etc/profile.d/nix.sh
|
|
||||||
fi
|
|
||||||
if hash eza 2>/dev/null; then
|
|
||||||
function ls {
|
|
||||||
if [[ "$@" =~ "-a" || "$@" =~ "-A" || "$@" =~ "--all" || "$@" =~ "--almost-all" ]]; then
|
|
||||||
eza --icons --long $@
|
|
||||||
else
|
|
||||||
eza --icons --long --ignore-glob "$([[ -f .hidden ]] && cat .hidden | tr '\n' '|')" $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Dotfiles management
|
|
||||||
# TODO: Rewrite to use bash read instead of zsh read
|
|
||||||
function .add {
|
|
||||||
if [[ -z $1 || -z $2 ]]; then
|
|
||||||
echo "Usage: .add <file> <message>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
chezmoi add $1
|
|
||||||
chezmoi git add .
|
|
||||||
chezmoi git status
|
|
||||||
read -p "Commit changes? [y/N] " -r answer
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
|
||||||
chezmoi git -- commit -m "$2"
|
|
||||||
read -p "Push changes? [y/N] " -r answer
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
|
||||||
chezmoi git push
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
# TODO: Rewrite to use bash read instead of zsh read
|
|
||||||
function .re-add {
|
|
||||||
if [[ -z $1 ]]; then
|
|
||||||
echo "Usage: .re-add <message>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
chezmoi re-add
|
|
||||||
chezmoi git status
|
|
||||||
chezmoi git diff
|
|
||||||
read -p "Commit changes? [y/N] " -r answer
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
|
||||||
chezmoi git -- commit -am "$1"
|
|
||||||
read -p "Push changes? [y/N] " -r answer
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
|
||||||
chezmoi git push
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
alias .push="chezmoi git push"
|
|
||||||
alias .pull="chezmoi git pull"
|
|
||||||
alias .status="chezmoi git status"
|
|
||||||
alias .diff="chezmoi git diff"
|
|
||||||
alias .update="chezmoi update"
|
|
||||||
|
|
||||||
# XDG stuff
|
|
||||||
export HISTFILE="${XDG_STATE_HOME}"/bash/history
|
|
||||||
|
|
||||||
# XDG aliases
|
|
||||||
alias wget="wget --hsts-file='$XDG_DATA_HOME/wget-hsts'"
|
|
||||||
alias yarn="yarn --use-yarnrc '$XDG_CONFIG_HOME/yarn/config'"
|
|
||||||
alias units="units --history '$XDG_DATA_HOME/units_history'"
|
|
||||||
alias nvidia-settings="nvidia-settings --config='$XDG_CONFIG_HOME/nvidia/settings'"
|
|
||||||
alias adb="HOME='$XDG_DATA_HOME/android' adb"
|
|
||||||
|
|
||||||
# Helpful tool: https://bash-prompt-generator.org
|
# Helpful tool: https://bash-prompt-generator.org
|
||||||
# On github: https://github.com/Scriptim/bash-prompt-generator
|
# On github: https://github.com/Scriptim/bash-prompt-generator
|
||||||
@ -128,5 +26,5 @@ PS1='[\u@\h \w]\$ '
|
|||||||
# Starship after defining custom prompt, easy to remove
|
# Starship after defining custom prompt, easy to remove
|
||||||
eval "$(starship init bash)"
|
eval "$(starship init bash)"
|
||||||
|
|
||||||
# Zoxide
|
# Zoxide init has to be last
|
||||||
eval "$(zoxide init bash)"
|
eval "$(zoxide init bash)"
|
||||||
|
@ -1,116 +1,41 @@
|
|||||||
|
# shellcheck shell=bash
|
||||||
|
# shellcheck disable=SC1090,SC1091,SC2034
|
||||||
|
|
||||||
# If not running interactively, don't do anything
|
# If not running interactively, don't do anything
|
||||||
[[ $- != *i* ]] && return
|
[[ $- != *i* ]] && return
|
||||||
|
|
||||||
# Required init for cli programs
|
[[ -f $XDG_CONFIG_HOME/bash/.bash_aliases ]] && source "$XDG_CONFIG_HOME/bash/.bash_aliases"
|
||||||
# Do not install completions unless no working, check /usr/share/bash-completion
|
|
||||||
autoload -Uz promptinit
|
autoload -Uz promptinit
|
||||||
autoload -Uz compinit
|
autoload -Uz compinit
|
||||||
promptinit
|
promptinit
|
||||||
compinit
|
compinit -d "$XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION"
|
||||||
|
|
||||||
|
# Some zsh plugins
|
||||||
|
[[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] && \
|
||||||
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||||
|
|
||||||
|
[[ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]] && \
|
||||||
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||||
|
|
||||||
# find-the-command
|
# find-the-command
|
||||||
# https://github.com/pkasemir/find-the-command
|
# https://github.com/pkasemir/find-the-command
|
||||||
|
[[ -f /usr/share/doc/find-the-command/ftc.zsh ]] && \
|
||||||
source /usr/share/doc/find-the-command/ftc.zsh noupdate quiet info
|
source /usr/share/doc/find-the-command/ftc.zsh noupdate quiet info
|
||||||
|
|
||||||
# Alternative
|
# Alternative (pkgfile)
|
||||||
# pkgfile
|
|
||||||
# https://wiki.archlinux.org/title/Pkgfile#Command_not_found
|
# https://wiki.archlinux.org/title/Pkgfile#Command_not_found
|
||||||
|
# [[ -f /usr/share/doc/pkgfile/command-not-found.zsh ]] && \
|
||||||
# source /usr/share/doc/pkgfile/command-not-found.zsh
|
# source /usr/share/doc/pkgfile/command-not-found.zsh
|
||||||
|
|
||||||
bindkey '^[[H' beginning-of-line
|
bindkey '^[[H' beginning-of-line
|
||||||
bindkey '^[[F' end-of-line
|
bindkey '^[[F' end-of-line
|
||||||
bindkey "^[[3~" delete-char
|
bindkey "^[[3~" delete-char
|
||||||
|
|
||||||
# Set aliases
|
|
||||||
alias grep="rg"
|
|
||||||
alias cd="z"
|
|
||||||
alias cat="bat -p"
|
|
||||||
alias find="fd"
|
|
||||||
alias bc="numbat"
|
|
||||||
#alias sed="sd"
|
|
||||||
alias du="dust"
|
|
||||||
alias tldr="tldr"
|
|
||||||
alias xxd="hexyl"
|
|
||||||
alias start="xdg-open"
|
|
||||||
alias edit="micro"
|
|
||||||
alias nano="micro"
|
|
||||||
alias gallery-dl="gallery-dl --cookies-from-browser firefox"
|
|
||||||
alias update-mirrors="rate-mirrors arch | sudo tee /etc/pacman.d/mirrorlist; rate-mirrors chaotic-aur | sudo tee /etc/pacman.d/chaotic-mirrorlist"
|
|
||||||
alias update="paru; paru -c; flatpak update"
|
|
||||||
alias rc="source ~/.config/zsh/.zshrc"
|
|
||||||
function clamav-exception-add {
|
|
||||||
if [[ -z $1 ]]; then
|
|
||||||
echo "Usage: clamav-exception-add <file>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if [[ ! -f $1 ]]; then
|
|
||||||
echo "File not found: $1"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
sudo bash -c "sigtool --sha256 "$1" >> /var/lib/clamav/user-defined-exceptions.sfp"
|
|
||||||
}
|
|
||||||
function ls {
|
|
||||||
if [[ "$@" =~ "-a" || "$@" =~ "-A" || "$@" =~ "--all" || "$@" =~ "--almost-all" ]]; then
|
|
||||||
eza --icons --long $@
|
|
||||||
else
|
|
||||||
eza --icons --long --ignore-glob "$([[ -f .hidden ]] && cat .hidden | tr '\n' '|')" $@
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Dotfiles management
|
# Zsh XDG history
|
||||||
function .add {
|
|
||||||
if [[ -z $1 || -z $2 ]]; then
|
|
||||||
echo "Usage: .add <file> <message>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
chezmoi add "$1"
|
|
||||||
chezmoi git add .
|
|
||||||
chezmoi git status
|
|
||||||
read -r "Commit changes? [y/N] " answer
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
|
||||||
chezmoi git commit -- -am "$2"
|
|
||||||
read -r "Push changes? [y/N] " answer
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
|
||||||
chezmoi git push
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
function .re-add {
|
|
||||||
if [[ -z $1 ]]; then
|
|
||||||
echo "Usage: .re-add <message>"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
chezmoi re-add
|
|
||||||
chezmoi git status
|
|
||||||
chezmoi git diff
|
|
||||||
read -r "?Commit changes? [y/N] " answer
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
|
||||||
chezmoi git commit -- -am "$1"
|
|
||||||
read -r "?Push changes? [y/N] " answer
|
|
||||||
if [[ $answer =~ ^[Yy]$ ]]; then
|
|
||||||
chezmoi git push
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
alias .push="chezmoi git push"
|
|
||||||
alias .pull="chezmoi git pull"
|
|
||||||
alias .status="chezmoi git status"
|
|
||||||
alias .diff="chezmoi git diff"
|
|
||||||
alias .update="chezmoi update"
|
|
||||||
|
|
||||||
# XDG zsh stuff
|
|
||||||
compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
|
|
||||||
export HISTFILE="$XDG_STATE_HOME"/zsh/history
|
export HISTFILE="$XDG_STATE_HOME"/zsh/history
|
||||||
|
|
||||||
# XDG aliases
|
|
||||||
alias wget="wget --hsts-file='$XDG_DATA_HOME/wget-hsts'"
|
|
||||||
alias yarn="yarn --use-yarnrc '$XDG_CONFIG_HOME/yarn/config'"
|
|
||||||
alias units="units --history '$XDG_DATA_HOME/units_history'"
|
|
||||||
alias nvidia-settings="nvidia-settings --config='$XDG_CONFIG_HOME/nvidia/settings'"
|
|
||||||
alias adb="HOME='$XDG_DATA_HOME/android' adb"
|
|
||||||
|
|
||||||
# Helpful tool: https://zsh-prompt-generator.site/
|
# Helpful tool: https://zsh-prompt-generator.site/
|
||||||
# On github: https://github.com/k-yokoishi/zsh-prompt-generator
|
# On github: https://github.com/k-yokoishi/zsh-prompt-generator
|
||||||
@ -120,5 +45,5 @@ RPROMPT="%?:%h | %*"
|
|||||||
# Starship after defining custom prompt, easy to remove
|
# Starship after defining custom prompt, easy to remove
|
||||||
eval "$(starship init zsh)"
|
eval "$(starship init zsh)"
|
||||||
|
|
||||||
# Zoxide
|
# Zoxide init has to be last
|
||||||
eval "$(zoxide init zsh)"
|
eval "$(zoxide init zsh)"
|
||||||
|
Reference in New Issue
Block a user