Added ex() function to .bashrc - used to ex(tract) any filetype
This commit is contained in:
40
bash/.bashrc
40
bash/.bashrc
@@ -73,3 +73,43 @@ unset command_not_found_handle
|
|||||||
if [ -f /usr/share/fzf/shell/key-bindings.bash ]; then
|
if [ -f /usr/share/fzf/shell/key-bindings.bash ]; then
|
||||||
source /usr/share/fzf/shell/key-bindings.bash
|
source /usr/share/fzf/shell/key-bindings.bash
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
ex() {
|
||||||
|
local c e i
|
||||||
|
|
||||||
|
(($#)) || return
|
||||||
|
|
||||||
|
for i; do
|
||||||
|
c=''
|
||||||
|
e=1
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo "No file specified"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -r $i ]]; then
|
||||||
|
echo "$0: file is unreadable: \`$i'" >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $i in
|
||||||
|
*.tar) c=(tar xf);;
|
||||||
|
*.7z) c=(7z x);;
|
||||||
|
*.Z) c=(uncompress);;
|
||||||
|
*.bz2) c=(bunzip2);;
|
||||||
|
*.exe) c=(cabextract);;
|
||||||
|
*.gz) c=(gunzip);;
|
||||||
|
*.rar) c=(unrar x);;
|
||||||
|
*.xz) c=(unxz);;
|
||||||
|
*.zip) c=(unzip);;
|
||||||
|
*) echo "$0: unrecognized file extension: \`$i'" >&2
|
||||||
|
continue;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
command "${c[@]}" "$i"
|
||||||
|
((e = e || $?))
|
||||||
|
done
|
||||||
|
return "$e"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user