diff options
Diffstat (limited to 'bash/dot-config')
| -rw-r--r-- | bash/dot-config/bash/functions.bash | 56 |
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 "$@" } - |
