aboutsummaryrefslogtreecommitdiff
path: root/bash/dot-config
diff options
context:
space:
mode:
authorMohammad Reza Karimi <m.r.karimi.j@gmail.com>2026-01-24 19:24:55 -0500
committerMohammad Reza Karimi <m.r.karimi.j@gmail.com>2026-01-24 19:24:55 -0500
commite2a70a92822b22633562e9695c300efec2b5cbeb (patch)
treefbd1658be1ab5edb1470d9a8e4b758818cc7124c /bash/dot-config
parent4052357e021085bc1c761108446ee09a778ade15 (diff)
updates
Diffstat (limited to 'bash/dot-config')
-rw-r--r--bash/dot-config/bash/functions.bash56
1 files changed, 31 insertions, 25 deletions
diff --git a/bash/dot-config/bash/functions.bash b/bash/dot-config/bash/functions.bash
index a8c0a65..2c9e873 100644
--- a/bash/dot-config/bash/functions.bash
+++ b/bash/dot-config/bash/functions.bash
@@ -3,64 +3,70 @@ source "${XDG_CONFIG_HOME:-$HOME/.config}"/bash/vardump.bash
colors()
{
- local i
- for i in {0..255}; do
- printf "\x1b[38;5;${i}mcolor %d\n" "$i"
- done
- tput sgr0
+ local i
+ for i in {0..255}; do
+ printf "\x1b[38;5;${i}mcolor %d\n" "$i"
+ done
+ tput sgr0
}
nman()
{
- nvim -c "Man $*" -c "wincmd o" -c "nmap q :q"
+ nvim -c "Man $*" -c "wincmd o" -c "nmap q :q"
}
lf()
{
- export LF_CD_FILE=/tmp/.lfcd-$$
- command lf "$@"
- if [ -s "$LF_CD_FILE" ]; then
- local DIR
- DIR="$(realpath "$(cat "$LF_CD_FILE")")"
- if [ "$DIR" != "$PWD" ]; then
- echo "cd to $DIR"
- cd "$DIR" || exit
+ export LF_CD_FILE=/tmp/.lfcd-$$
+ command lf "$@"
+ if [ -s "$LF_CD_FILE" ]; then
+ local DIR
+ DIR="$(realpath "$(cat "$LF_CD_FILE")")"
+ if [ "$DIR" != "$PWD" ]; then
+ echo "cd to $DIR"
+ cd "$DIR" || exit
+ fi
+ command rm "$LF_CD_FILE"
fi
- command rm "$LF_CD_FILE"
- fi
- unset LF_CD_FILE
+ unset LF_CD_FILE
}
se()
{
- choice="$(fd . ~/.local/bin -d1 -tx -tl --format '{/}' | fzf)"
- [ -f "$HOME/.local/bin/$choice" ] && $EDITOR "$HOME/.local/bin/$choice"
+ choice="$(fd . ~/.local/bin -d1 -tx -tl --format '{/}' | fzf)"
+ [ -f "$HOME/.local/bin/$choice" ] && $EDITOR "$HOME/.local/bin/$choice"
}
pS()
{
- pacman -Slq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S
+ pacman -Slq | fzf --multi --preview 'pacman -Si {1}' | xargs -ro sudo pacman -S
}
paruS()
{
- paru -Slq | fzf --multi --preview 'paru -Si {1}' | xargs -ro paru -S
+ paru -Slq | fzf --multi --preview 'paru -Si {1}' | xargs -ro paru -S
}
yayS()
{
- yay -Slq | fzf --multi --preview 'yay -Si {1}' | xargs -ro yay -S
+ yay -Slq | fzf --multi --preview 'yay -Si {1}' | xargs -ro yay -S
}
# cp and mv but with rsync
# source: https://wiki.archlinux.org/title/Rsync#As_cp/mv_alternative
cpr()
{
- rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 "$@"
+ set -xe
+ local rsync_args="--archive -hh --partial --info=stats1,progress2 --modify-window=1"
+ if [ "$1" = "-sudo" ]; then
+ shift
+ sudo rsync $rsync_args "$@"
+ else
+ rsync $rsync_args "$@"
+ fi
}
mvr()
{
- rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 --remove-source-files "$@"
+ rsync --archive -hh --partial --info=stats1,progress2 --modify-window=1 --remove-source-files "$@"
}
-