]> git repos ~mattia - some.files.git/commitdiff
Procedured and README
authorMattia Cabrini <dev@mattiacabrini.com>
Tue, 11 Feb 2025 21:33:26 +0000 (22:33 +0100)
committerMattia Cabrini <dev@mattiacabrini.com>
Tue, 11 Feb 2025 21:33:26 +0000 (22:33 +0100)
.bashrc
.config/some.files/bash/procedures/ex.sh [new file with mode: 0644]
README.md

diff --git a/.bashrc b/.bashrc
index 73d46f40c544c5443af709c6085116492f47af14..e87042d9494b56494671dc8624cf132f0698055d 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -19,31 +19,6 @@ HISTFILESIZE=2000
 
 # export PS1="\[\033[m\][\[\033[1;35m\]\t\[\033[m\]] \[\e[2m\]\u\[\e[1;36m\]\[\033[m\]@\[\e[1;36m\]\h\[\033[m\]:\[\e[0m\]\[\e[1;32m\]\W\[\e[0m\]\[\e[2m\]\$ \[\e[0m\]"
 
-#
-# # ex - archive extractor
-# # usage: ex <file>
-ex ()
-{
-  if [ -f $1 ] ; then
-    case $1 in
-      *.tar.bz2)   tar -xvjf $1   ;;
-      *.tar.gz)    tar -xvzf $1   ;;
-      *.bz2)       bunzip2 $1   ;;
-      *.rar)       unrar x $1     ;;
-      *.gz)        gunzip $1    ;;
-      *.tar)       tar -xvf $1    ;;
-      *.tbz2)      tar -xvjf $1   ;;
-      *.tgz)       tar -xvzf $1   ;;
-      *.zip)       unzip $1     ;;
-      *.Z)         uncompress $1;;
-      *.7z)        7z x $1      ;;
-      *)           echo "'$1' cannot be extracted via ex()" ;;
-    esac
-  else
-    echo "'$1' is not a valid file"
-  fi
-}
-
 # User defined aliases
 if [ -f ~/.bash_aliases ]; then
     . ~/.bash_aliases
diff --git a/.config/some.files/bash/procedures/ex.sh b/.config/some.files/bash/procedures/ex.sh
new file mode 100644 (file)
index 0000000..f98dcc3
--- /dev/null
@@ -0,0 +1,23 @@
+# $1: file to extract 
+ex ()
+{
+  if [ -f $1 ] ; then
+    case $1 in
+      *.tar.bz2)   tar -xvjf $1   ;;
+      *.tar.gz)    tar -xvzf $1   ;;
+      *.bz2)       bunzip2 $1   ;;
+      *.rar)       unrar x $1     ;;
+      *.gz)        gunzip $1    ;;
+      *.tar)       tar -xvf $1    ;;
+      *.tbz2)      tar -xvjf $1   ;;
+      *.tgz)       tar -xvzf $1   ;;
+      *.zip)       unzip $1     ;;
+      *.Z)         uncompress $1;;
+      *.7z)        7z x $1      ;;
+      *)           echo "'$1' is not supported" ;;
+    esac
+  else
+    echo "'$1' is not a file"
+  fi
+}
+
index 7d1df5b22da13b9a2d9df40bbab5094942dcd861..2fc6be4985b3e8450894a72c30e281750a8ebfd0 100644 (file)
--- a/README.md
+++ b/README.md
@@ -4,8 +4,10 @@ In this repository I collect some of my personal .files.
 ## Shell(s)
 I use bash on Lunux and zsh on MacOS, therefore I have and RC for both of them. Their design are similar: they define a prompt and some simple functions and include:
 
-- `~/.*sh_aliases`: a file in which the user can insert additional aliases without changing the RC file. Additional aliases are not included for non-interactive shells;
-- `~/.*sh_env`: a file in which the user is supposed to insert the environment variables or exports without changing the RC file. Since every system is different, the file is not included in the repository.
+- `~/.*sh_aliases`: it defines simple cross machine alases (evaluated from \*shrc);
+- `~/.*sh_env`: contanins definitions for machine specific environment variables (evaluated from \*shrc);
+- `~/.config/some.files/bash/env.sh`: contains definitions for cross machine environment variables (evaluated from .bashrc);
+- `~/.config/some.files/bash/procedures/*.sh`: each file is evaluated from .bashrc and is supposed to contain definitions for bash procedures;
 
 ### Dependencies