From e11c7cf39fb2a09348ae4982814f214c498b5191 Mon Sep 17 00:00:00 2001 From: TrudeEH Date: Fri, 14 Mar 2025 09:24:33 +0000 Subject: [PATCH] Enhance extract function --- home/.bashrc | 75 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 58 insertions(+), 17 deletions(-) diff --git a/home/.bashrc b/home/.bashrc index 5815b1a0..6c3fe253 100644 --- a/home/.bashrc +++ b/home/.bashrc @@ -1,21 +1,58 @@ +source $HOME/.local/bin/p.sh + export EDITOR="vim" export PS1="\n[\[\e[37m\]\u\[\e[0m\]@\[\e[37;2m\]\h\[\e[0m\]] \[\e[1m\]\w \[\e[0;2m\]J:\[\e[0m\]\j\n\$ " extract() { - if [ -f $1 ]; then - case $1 in - *.tar.bz2) tar xjf $1 ;; - *.tar.gz) tar xzf $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) unrar e $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xf $1 ;; - *.tbz2) tar xjf $1 ;; - *.tgz) tar xzf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1 ;; - *.7z) 7z x $1 ;; - *) echo "'$1' cannot be extracted via extract()" ;; + if [ -f "$1" ]; then + case "$1" in + *.tar.bz2) + command -v tar >/dev/null || p i tar + tar xjf "$1" + ;; + *.tar.gz) + command -v tar >/dev/null || p i tar + tar xzf "$1" + ;; + *.bz2) + command -v bunzip2 >/dev/null || p i bzip2 + bunzip2 "$1" + ;; + *.rar) + command -v unrar >/dev/null || p i unrar + unrar e "$1" + ;; + *.gz) + command -v gunzip >/dev/null || p i gzip + gunzip "$1" + ;; + *.tar) + command -v tar >/dev/null || p i tar + tar xf "$1" + ;; + *.tbz2) + command -v tar >/dev/null || p i tar + tar xjf "$1" + ;; + *.tgz) + command -v tar >/dev/null || p i tar + tar xzf "$1" + ;; + *.zip) + command -v unzip >/dev/null || p i unzip + unzip "$1" + ;; + *.Z) + command -v uncompress >/dev/null || p i ncompress + uncompress "$1" + ;; + *.7z) + command -v 7z >/dev/null || p i p7zip + 7z x "$1" + ;; + *) + echo "'$1' cannot be extracted via extract()" + ;; esac else echo "'$1' is not a valid file" @@ -46,11 +83,15 @@ alias ta="tmux attach" set completion-ignore-case On -# Use bash-completion, if available -[[ $PS1 && -f /usr/share/bash-completion/bash_completion ]] && +# bash-completion +if [ ! -f /usr/share/bash-completion/bash_completion ]; then + p i bash-completion +fi + +if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion +fi export OFLAGS="--ozone-platform-hint=auto" export PATH=$PATH:$HOME/.local/bin -source $HOME/.local/bin/p.sh