aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
Diffstat (limited to 'bash')
-rw-r--r--bash/dot-bashrc26
-rw-r--r--bash/dot-config/bash/gentoo-color.bash6
-rw-r--r--bash/dot-config/bash/path.bash202
-rw-r--r--bash/dot-config/shellshort/bm-dirs0
-rw-r--r--bash/dot-config/shellshort/bm-files5
-rw-r--r--bash/dot-config/shellshort/shortcutrc6
-rw-r--r--bash/dot-profile16
7 files changed, 243 insertions, 18 deletions
diff --git a/bash/dot-bashrc b/bash/dot-bashrc
index 678235f..cc9c324 100644
--- a/bash/dot-bashrc
+++ b/bash/dot-bashrc
@@ -14,21 +14,15 @@ shopt -s checkwinsize
source "${XDG_CONFIG_HOME:-$HOME/.config}"/bash/gentoo-color.bash
-ls()
+function ls()
{
- if ((gentoo_color > 0)); then
- command ls --color=auto "$@"
- else
- command ls "$@"
- fi
+ command ls --color=auto --indicator-style=classify --human-readable --literal --group-directories-first -v "$@" # -v is for natural sort of numbers within text
}
# coreutils
alias cp='cp -riv'
-alias la='ls -la'
-alias ll='ls -lah'
+alias ll='ls --all -l --human-readable' # -l = long listing format
alias l='ls -l'
-alias ls='ls -p -hN --group-directories-first'
alias mkdir='mkdir -pv'
alias mv='mv -iv'
alias rm='rm -iv'
@@ -36,12 +30,16 @@ alias ..='echo "cd .."; cd ..'
alias ...='echo "cd ../.."; cd ../..'
# program aliases
-alias m='neomutt'
+alias m='aerc'
alias p='sudo pacman'
alias SS='sudo systemctl'
alias Su='systemctl --user'
alias v='nvim'
+alias vn='NVIM_APPNAME=nvim-final nvim'
+alias vv='uv run nvim'
alias z='setsid runapp -- zathura'
+alias todo='nvim ~/system-notes.md'
+alias neofetch='fastfetch -c examples/13'
# source: https://wiki.archlinux.org/title/GnuPG#Configure_pinentry_to_use_the_correct_TTY
GPG_TTY="$(tty)"
@@ -50,11 +48,13 @@ gpg-connect-agent updatestartuptty /bye >/dev/null
# cp and mv but with rsync
# source: https://wiki.archlinux.org/title/Rsync#As_cp/mv_alternative
-cpr() {
+cpr()
+{
rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 "$@"
}
-mvr() {
+mvr()
+{
rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 --remove-source-files "$@"
}
@@ -62,6 +62,8 @@ source "${XDG_CONFIG_HOME:-$HOME/.config}"/bash/functions.bash
bind '"\C-o":"\C-ulf\C-m"'
+source "${XDG_CONFIG_HOME:-$HOME/.config}"/shellshort/shortcutrc
+
export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix --hidden --follow --exclude .git'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
eval "$(fzf --bash)"
diff --git a/bash/dot-config/bash/gentoo-color.bash b/bash/dot-config/bash/gentoo-color.bash
index f2a168d..a9abef8 100644
--- a/bash/dot-config/bash/gentoo-color.bash
+++ b/bash/dot-config/bash/gentoo-color.bash
@@ -2,9 +2,7 @@
#
# source: https://gitweb.gentoo.org/repo/gentoo.git/plain/app-shells/bash/files/bashrc.d/10-gentoo-color-r2.bash
# changes:
-# - remove ls from the list of aliases (will configure it myself in bashrc)
# - comment dircolor stuff at the end (don't like too many colors)
-# - comment the unset gentoo_color, since I use it later for ls
#
# NOTE: copy this file for the root user and source it in its bashrc as well:
# root # cp /home/moreka/.config/bash/gentoo-color.bash ~/.gentoo-color.bash
@@ -61,7 +59,7 @@ fi
if (( gentoo_color > 0 )); then
# Colorize the output of diff(1), grep(1) and a few coreutils utilities.
# However, do so only where no alias/function by the given name exists.
- for _ in diff dir grep vdir; do
+ for _ in ls diff dir grep vdir; do
if [[ $(type -t "$_") == file ]]; then
alias "$_=$_ --color=auto"
fi
@@ -80,4 +78,4 @@ if (( gentoo_color > 0 )); then
# fi
fi
-# unset -v gentoo_color
+unset -v gentoo_color
diff --git a/bash/dot-config/bash/path.bash b/bash/dot-config/bash/path.bash
new file mode 100644
index 0000000..b4bcf55
--- /dev/null
+++ b/bash/dot-config/bash/path.bash
@@ -0,0 +1,202 @@
+#!/usr/bin/env bash
+#
+# Functions to modify colon separated variables like $PATH or $MANPATH
+#
+# Author: Dave Eddy <dave@daveeddy.com>
+# Date: September 07, 2018
+# License: MIT
+# Source: https://github.com/bahamas10/bash-path/blob/master/path.bash
+
+#
+# path_add <path> [direction] [varname]
+#
+# path_add takes a directory name, an optional direction name (defaults to
+# "after" to append to list) and an optional variable name (defaults to PATH)
+# and adds the directory name to data stored in variable.
+#
+# Example
+#
+# given: PATH='/bin:/sbin'
+#
+# path_add /usr/bin
+# // PATH => '/bin:/sbin:/usr/bin'
+# path_add /opt/local/bin before
+# // PATH => '/opt/local/bin:/bin:/sbin:/usr/bin'
+#
+# The variable name should be passed by name.
+# foo=''
+# path_add /bin after foo
+# // foo => '/bin'
+#
+path_add() {
+ local var=${3:-PATH}
+ local path=
+ path=$(path_print_add "$@") || return 1
+ read -r "${var?}" <<< "$path"
+}
+
+#
+# path_remove <path> [varname]
+#
+# path_remove takes a directory name and an optional variable name (defaults to
+# PATH) and removes every instance of the directory name from the data stored in
+# the variable.
+#
+# Example
+#
+# given: PATH='/bin:/sbin:/usr/bin:/usr/sbin'
+#
+# path_remove /usr/bin
+# // PATH => '/bin:/sbin:/usr/sbin'
+# path_remove /not-found
+# // PATH => '/bin:/sbin:/usr/sbin'
+#
+# The variable name should be passed by name.
+# foo='/bin:/sbin'
+# path_remove /bin foo
+# // foo => '/sbin'
+#
+path_remove() {
+ local var=${2:-PATH}
+ local path=
+ path=$(path_print_remove "$@") || return 1
+ read -r "${var?}" <<< "$path"
+}
+
+#
+# path_clean [varname]
+#
+# path_clean takes an optional variable name (defaults to PATH) and "cleans" it,
+# this process will:
+#
+# 1. Remove empty elements.
+# 2. Remove relative directories.
+# 3. Remove directories that don't exist/can't be accessed (checked with `cd`).
+# 4. Remove duplicates (first element stays, subsequent elements are tossed).
+#
+# Example
+#
+# PATH='::/bin:/sbin:::./:../../some-path::/doesnt-exist'
+# path_clean
+# // PATH => '/bin:/sbin'
+
+# PATH='/bin:/bin//:////bin//////:/bin/dir/..::'
+# path_clean
+# // PATH => '/bin'
+#
+# The variable name should be passed by name.
+# foo='/bin:/bin'
+# path_clean /bin foo
+# // foo => '/bin'
+#
+path_clean() {
+ local var=${1:-PATH}
+ local path=
+ path=$(path_print_clean "$@") || return 1
+ read -r "${var?}" <<< "$path"
+}
+
+#
+# Exact same usage as path_add but prints the new PATH only and doesn't modify
+# anything in place.
+#
+path_print_add() {
+ local p=$1
+ local dir=${2:-after}
+ local var=${3:-PATH}
+ local arr
+ declare -A seen
+
+ if [[ -z $p || $p == *:* ]]; then
+ echo "path_print_add: invalid argument: '$p'" >&2
+ return 1
+ fi
+
+ IFS=: read -ra arr <<< "${!var}:"
+
+ case "$dir" in
+ after) arr=("${arr[@]}" "$p");;
+ *) arr=("$p" "${arr[@]}");;
+ esac
+
+ local IFS=:
+ echo "${arr[*]}"
+}
+
+#
+# Exact same usage as path_remove but prints the new PATH only and doesn't
+# modify anything in place.
+#
+path_print_remove() {
+ local p=$1
+ local var=${2:-PATH}
+ local arr
+ local newarr=()
+ declare -A seen
+
+ if [[ -z $p || $p == *:* ]]; then
+ echo "path_print_remove: invalid argument: '$p'" >&2
+ return 1
+ fi
+
+ IFS=: read -ra arr <<< "${!var}:"
+
+ local _p
+ for _p in "${arr[@]}"; do
+ if [[ $p == "$_p" ]]; then
+ continue
+ fi
+ newarr+=("$_p")
+ done
+
+ local IFS=:
+ echo "${newarr[*]}"
+}
+
+#
+# Exact same usage as path_clean but prints the new PATH only and doesn't
+# modify anything in place.
+#
+path_print_clean() {
+ local var=${1:-PATH}
+ local arr
+ local newarr=()
+ declare -A seen
+
+ # read PATH into an array, trailing ":" is due to:
+ # http://mywiki.wooledge.org/BashPitfalls#pf47
+ IFS=: read -ra arr <<< "${!var}:"
+
+ local p
+ for p in "${arr[@]}"; do
+ # Empty element is equivalent to CWD (weird, I know), remove it
+ if [[ -z $p ]]; then
+ continue
+ fi
+
+ # Remove any relative paths
+ if [[ ${p:0:1} != '/' ]]; then
+ continue
+ fi
+
+ # Normalize path and ensure we can access it
+ p=$(cd "$p" &>/dev/null && echo "$PWD")
+
+ # Path doesn't exist or we can't access it
+ if [[ -z $p ]]; then
+ continue
+ fi
+
+ # Filter out dups while we are here
+ if [[ -n ${seen[$p]} ]]; then
+ continue
+ fi
+ seen[$p]=true
+
+ # Store the new path
+ newarr+=("$p")
+ done
+
+ local IFS=:
+ echo "${newarr[*]}"
+}
diff --git a/bash/dot-config/shellshort/bm-dirs b/bash/dot-config/shellshort/bm-dirs
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/bash/dot-config/shellshort/bm-dirs
diff --git a/bash/dot-config/shellshort/bm-files b/bash/dot-config/shellshort/bm-files
new file mode 100644
index 0000000..4e2b76d
--- /dev/null
+++ b/bash/dot-config/shellshort/bm-files
@@ -0,0 +1,5 @@
+cala $XDG_CONFIG_HOME/alacritty/alacritty.toml
+cgho $XDG_CONFIG_HOME/ghostty/config
+cvim $XDG_CONFIG_HOME/nvim/init.lua
+chy $XDG_CONFIG_HOME/hypr/hyprland.conf
+cway $XDG_CONFIG_HOME/waybar/config.jsonc
diff --git a/bash/dot-config/shellshort/shortcutrc b/bash/dot-config/shellshort/shortcutrc
new file mode 100644
index 0000000..1eebef3
--- /dev/null
+++ b/bash/dot-config/shellshort/shortcutrc
@@ -0,0 +1,6 @@
+# vim: filetype=sh
+alias cala="$EDITOR /home/moreka/.config/alacritty/alacritty.toml" \
+cgho="$EDITOR /home/moreka/.config/ghostty/config" \
+cvim="$EDITOR /home/moreka/.config/nvim/init.lua" \
+chy="$EDITOR /home/moreka/.config/hypr/hyprland.conf" \
+cway="$EDITOR /home/moreka/.config/waybar/config.jsonc" \
diff --git a/bash/dot-profile b/bash/dot-profile
index f726fcc..cd3f5cd 100644
--- a/bash/dot-profile
+++ b/bash/dot-profile
@@ -1,7 +1,5 @@
#!/bin/sh
-export PATH="$PATH:$HOME/.local/bin"
-
export EDITOR=nvim
export SUDO_EDITOR=$EDITOR
export BAT_THEME=ansi
@@ -14,6 +12,10 @@ export XDG_DATA_HOME="$HOME"/.local/share
export XDG_STATE_HOME="$HOME"/.local/state
export XDG_BIN_HOME="$HOME"/.local/bin
+source "$XDG_CONFIG_HOME"/bash/path.bash
+
+path_add "$XDG_BIN_HOME"
+
export LESSHISTFILE="$XDG_CACHE_HOME"/lesshst
export CARGO_HOME="$XDG_DATA_HOME"/cargo
export TEXMFHOME="$XDG_DATA_HOME"/texmf
@@ -23,6 +25,9 @@ export GOPATH="$XDG_DATA_HOME"/go
export GTK2_RC_FILES="$XDG_CONFIG_HOME"/gtk-2.0/gtkrc-2.0
export PASSWORD_STORE_DIR="$XDG_DATA_HOME"/pass
export NOTMUCH_CONFIG="$XDG_CONFIG_HOME"/notmuch/default/config
+export GEM_HOME="$(gem env user_gemhome 2>/dev/null)"
+
+[ -n "$GEM_HOME" ] && path_add "$GEM_HOME/bin"
# [ -d "$HOME/.nix-profile" ] && export XDG_DATA_DIRS="$HOME"/.nix-profile/share:"$XDG_DATA_DIRS"
# [ -d "$HOME/.nix-profile" ] && . "$HOME/.nix-profile/etc/profile.d/hm-session-vars.sh"
@@ -37,6 +42,13 @@ fi
export NO_AT_BRIDGE=1
export GTK_A11Y=none
+path_clean
+
+# if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ] && [ -z "$NIRI_LOADED" ]; then
+# export NIRI_LOADED=1
+# exec niri-session
+# fi
+
if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ] ; then
if uwsm check may-start; then
exec systemd-cat -t uwsm_start uwsm start hyprland.desktop