From 30bf096e814e9fd81eb5913950feb5d099578579 Mon Sep 17 00:00:00 2001 From: TrudeEH Date: Tue, 8 Apr 2025 11:29:46 +0100 Subject: [PATCH] Make extract a separate script --- home/.bashrc | 63 ++----------------------------------------------- scripts/extract | 57 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 61 deletions(-) create mode 100755 scripts/extract diff --git a/home/.bashrc b/home/.bashrc index 3c932d25..4ff69ab4 100644 --- a/home/.bashrc +++ b/home/.bashrc @@ -1,64 +1,6 @@ -source $HOME/.local/bin/p.sh - -export EDITOR="vim" +export EDITOR="vi" 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) - 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" - fi -} - # Commands that should be applied only for interactive shells. [[ $- == *i* ]] || return @@ -78,8 +20,7 @@ alias ll='ls -lhi' alias ta='tmux attach' alias t='tmux' alias v='nvim' -alias t="tmux" -alias ta="tmux attach" +alias t='tmux' if command -v batcat 2>&1 >/dev/null; then alias bat=batcat diff --git a/scripts/extract b/scripts/extract new file mode 100755 index 00000000..d19688b6 --- /dev/null +++ b/scripts/extract @@ -0,0 +1,57 @@ +#! /bin/bash + +extract() { + if [ -f "$1" ]; then + case "$1" in + *.tar.bz2) + command -v tar >/dev/null || sudo apt install -y tar + tar xjvf "$1" + ;; + *.tar.gz) + command -v tar >/dev/null || sudo apt install -y tar + tar xzvf "$1" + ;; + *.bz2) + command -v bunzip2 >/dev/null || sudo apt install -y bzip2 + bunzip2 "$1" + ;; + *.rar) + command -v unrar >/dev/null || sudo apt install -y unrar + unrar e "$1" + ;; + *.gz) + command -v gunzip >/dev/null || sudo apt install -y gzip + gunzip "$1" + ;; + *.tar) + command -v tar >/dev/null || sudo apt install -y tar + tar xf "$1" + ;; + *.tbz2) + command -v tar >/dev/null || sudo apt install -y tar + tar xjf "$1" + ;; + *.tgz) + command -v tar >/dev/null || sudo apt install -y tar + tar xzf "$1" + ;; + *.zip) + command -v unzip >/dev/null || sudo apt install -y unzip + unzip "$1" + ;; + *.Z) + command -v uncompress >/dev/null || sudo apt install -y ncompress + uncompress "$1" + ;; + *.7z) + command -v 7z >/dev/null || sudo apt install -y p7zip + 7z x "$1" + ;; + *) + echo "'$1' cannot be extracted via extract()" + ;; + esac + else + echo "'$1' is not a valid file" + fi +}