Merge 1671df94f6 into 23ac376f10
commit
1c639cd9b9
|
|
@ -0,0 +1,26 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
about-alias 'Shortcuts for directory commands: ls, cd, &c.'
|
||||||
|
|
||||||
|
if command ls --color -d . &> /dev/null; then
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
# BSD `ls` doesn't need an argument (`-G`) when `$CLICOLOR` is set.
|
||||||
|
fi
|
||||||
|
|
||||||
|
# List directory contents
|
||||||
|
alias sl=ls
|
||||||
|
alias la='ls -AF' # Compact view, show hidden
|
||||||
|
alias ll='ls -Al'
|
||||||
|
alias l='ls -A'
|
||||||
|
alias l1='ls -1'
|
||||||
|
alias lf='ls -F'
|
||||||
|
|
||||||
|
# Change directory
|
||||||
|
alias ..='cd ..' # Go up one directory
|
||||||
|
alias cd..='cd ..' # Common misspelling for going up one directory
|
||||||
|
alias ...='cd ../..' # Go up two directories
|
||||||
|
alias ....='cd ../../..' # Go up three directories
|
||||||
|
alias -- -='cd -' # Go back
|
||||||
|
|
||||||
|
# Create or remove directory
|
||||||
|
alias md='mkdir -p'
|
||||||
|
alias rd='rmdir'
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
# shellcheck shell=bash
|
||||||
|
about-alias 'shortcuts for editing'
|
||||||
|
|
||||||
|
alias edit='${EDITOR:-${ALTERNATE_EDITOR:-nano}}'
|
||||||
|
alias e='edit'
|
||||||
|
|
||||||
|
# sudo editors
|
||||||
|
alias svim='sudo ${VISUAL:-vim}'
|
||||||
|
alias snano='sudo ${ALTERNATE_EDITOR:-nano}'
|
||||||
|
alias sedit='sudo ${EDITOR:-${ALTERNATE_EDITOR:-nano}}'
|
||||||
|
|
||||||
|
# Shortcuts to edit startup files
|
||||||
|
alias vbrc='${VISUAL:-vim} ~/.bashrc'
|
||||||
|
alias vbpf='${VISUAL:-vim} ~/.bash_profile'
|
||||||
|
|
@ -1,25 +1,9 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
# shellcheck source-path=SCRIPTDIR
|
||||||
about-alias 'general aliases'
|
about-alias 'general aliases'
|
||||||
|
|
||||||
if command ls --color -d . &> /dev/null; then
|
|
||||||
alias ls='ls --color=auto'
|
|
||||||
# BSD `ls` doesn't need an argument (`-G`) when `$CLICOLOR` is set.
|
|
||||||
fi
|
|
||||||
|
|
||||||
# List directory contents
|
|
||||||
alias sl=ls
|
|
||||||
alias la='ls -AF' # Compact view, show hidden
|
|
||||||
alias ll='ls -al'
|
|
||||||
alias l='ls -a'
|
|
||||||
alias l1='ls -1'
|
|
||||||
alias lf='ls -F'
|
|
||||||
|
|
||||||
alias _='sudo'
|
alias _='sudo'
|
||||||
|
|
||||||
# Shortcuts to edit startup files
|
|
||||||
alias vbrc='${VISUAL:-vim} ~/.bashrc'
|
|
||||||
alias vbpf='${VISUAL:-vim} ~/.bash_profile'
|
|
||||||
|
|
||||||
# colored grep
|
# colored grep
|
||||||
# Need to check an existing file for a pattern that will be found to ensure
|
# Need to check an existing file for a pattern that will be found to ensure
|
||||||
# that the check works when on an OS that supports the color option
|
# that the check works when on an OS that supports the color option
|
||||||
|
|
@ -34,12 +18,11 @@ fi
|
||||||
alias c='clear'
|
alias c='clear'
|
||||||
alias cls='clear'
|
alias cls='clear'
|
||||||
|
|
||||||
alias edit='${EDITOR:-${ALTERNATE_EDITOR?}}'
|
alias pager='${PAGER:-less}'
|
||||||
alias pager='${PAGER:=less}'
|
|
||||||
|
|
||||||
alias q='exit'
|
alias q='exit'
|
||||||
|
|
||||||
alias irc='${IRC_CLIENT:=irc}'
|
alias irc='${IRC_CLIENT:-irc}'
|
||||||
|
|
||||||
# Language aliases
|
# Language aliases
|
||||||
alias rb='ruby'
|
alias rb='ruby'
|
||||||
|
|
@ -47,14 +30,9 @@ alias py='python'
|
||||||
alias ipy='ipython'
|
alias ipy='ipython'
|
||||||
|
|
||||||
# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/
|
# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/
|
||||||
|
if _command_exists pianobar; then
|
||||||
alias piano='pianobar'
|
alias piano='pianobar'
|
||||||
|
fi
|
||||||
alias ..='cd ..' # Go up one directory
|
|
||||||
alias cd..='cd ..' # Common misspelling for going up one directory
|
|
||||||
alias ...='cd ../..' # Go up two directories
|
|
||||||
alias ....='cd ../../..' # Go up three directories
|
|
||||||
alias -- -='cd -' # Go back
|
|
||||||
|
|
||||||
# Shell History
|
# Shell History
|
||||||
alias h='history'
|
alias h='history'
|
||||||
|
|
@ -64,17 +42,6 @@ if ! _command_exists tree; then
|
||||||
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
|
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Directory
|
|
||||||
alias md='mkdir -p'
|
|
||||||
alias rd='rmdir'
|
|
||||||
|
|
||||||
# Shorten extract
|
|
||||||
alias xt='extract'
|
|
||||||
|
|
||||||
# sudo editors
|
|
||||||
alias svim='sudo ${VISUAL:-vim}'
|
|
||||||
alias snano='sudo nano'
|
|
||||||
|
|
||||||
# Display whatever file is regular file or folder
|
# Display whatever file is regular file or folder
|
||||||
function catt() {
|
function catt() {
|
||||||
for i in "$@"; do
|
for i in "$@"; do
|
||||||
|
|
@ -92,5 +59,6 @@ function catt() {
|
||||||
# aliases and enable just the ones for Bash-it explicitly:
|
# aliases and enable just the ones for Bash-it explicitly:
|
||||||
# bash-it disable alias general
|
# bash-it disable alias general
|
||||||
# bash-it enable alias bash-it
|
# bash-it enable alias bash-it
|
||||||
# shellcheck source-path=SCRIPTDIR
|
|
||||||
source "$BASH_IT/aliases/available/bash-it.aliases.bash"
|
source "$BASH_IT/aliases/available/bash-it.aliases.bash"
|
||||||
|
source "$BASH_IT/aliases/available/directory.aliases.bash"
|
||||||
|
source "$BASH_IT/aliases/available/editor.aliases.bash"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
about-alias 'vim abbreviations'
|
about-alias 'vim abbreviations'
|
||||||
|
|
||||||
_command_exists vim || return
|
alias v='${VISUAL:-vim}'
|
||||||
|
|
||||||
alias v='vim'
|
if ! _command_exists vim; then
|
||||||
|
_log_warning "Without 'vim', these aliases just aren't that useful..."
|
||||||
|
fi
|
||||||
# open the vim help in fullscreen incorporated from
|
# open the vim help in fullscreen incorporated from
|
||||||
# https://stackoverflow.com/a/4687513
|
# https://stackoverflow.com/a/4687513
|
||||||
alias vimh='vim -c ":h | only"'
|
alias vimh='vim -c ":h | only"'
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ plugins/available/colors.plugin.bash
|
||||||
plugins/available/direnv.plugin.bash
|
plugins/available/direnv.plugin.bash
|
||||||
plugins/available/dirs.plugin.bash
|
plugins/available/dirs.plugin.bash
|
||||||
plugins/available/docker-machine.plugin.bash
|
plugins/available/docker-machine.plugin.bash
|
||||||
|
plugins/available/extract.plugin.bash
|
||||||
plugins/available/gif.plugin.bash
|
plugins/available/gif.plugin.bash
|
||||||
plugins/available/git-subrepo.plugin.bash
|
plugins/available/git-subrepo.plugin.bash
|
||||||
plugins/available/git.plugin.bash
|
plugins/available/git.plugin.bash
|
||||||
|
|
|
||||||
|
|
@ -1,73 +1,84 @@
|
||||||
cite about-plugin
|
# shellcheck shell=bash
|
||||||
about-plugin 'one command to extract them all...'
|
about-plugin 'one command to extract them all...'
|
||||||
|
|
||||||
# extract file(s) from compressed status
|
# extract file(s) from compressed status
|
||||||
extract() {
|
function extract() {
|
||||||
local opt
|
local opt OPTIND=1 verbose
|
||||||
local OPTIND=1
|
local filename filedirname targetdirname
|
||||||
while getopts "hv" opt; do
|
while getopts "hv" opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
h)
|
h)
|
||||||
cat <<End-Of-Usage
|
cat << EOU
|
||||||
Usage: ${FUNCNAME[0]} [option] <archives>
|
Usage: ${FUNCNAME[0]} [option] <archives>
|
||||||
options:
|
options:
|
||||||
-h show this message and exit
|
-h show this message and exit
|
||||||
-v verbosely list files processed
|
-v verbosely list files processed
|
||||||
End-Of-Usage
|
EOU
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
v)
|
v)
|
||||||
local -r verbose='v'
|
local -r verbose='v'
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
extract -h >&2
|
extract -h >&2
|
||||||
return 1
|
return 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $((OPTIND-1))
|
shift $((OPTIND - 1))
|
||||||
|
|
||||||
[ $# -eq 0 ] && extract -h && return 1
|
if [[ $# -eq 0 ]]; then
|
||||||
while [ $# -gt 0 ]; do
|
extract -h
|
||||||
if [[ ! -f "$1" ]]; then
|
return 1
|
||||||
echo "extract: '$1' is not a valid file" >&2
|
fi
|
||||||
shift
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
local -r filename=$(basename -- $1)
|
while [[ $# -gt 0 ]]; do
|
||||||
local -r filedirname=$(dirname -- $1)
|
if [[ ! -f "${1:-}" ]]; then
|
||||||
local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< $filename)
|
echo "extract: '$1' is not a valid file" >&2
|
||||||
if [ "$filename" = "$targetdirname" ]; then
|
shift
|
||||||
# archive type either not supported or it doesn't need dir creation
|
continue
|
||||||
targetdirname=""
|
fi
|
||||||
else
|
|
||||||
mkdir -v "$filedirname/$targetdirname"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$1" ]; then
|
local -r filename=$(basename -- "$1")
|
||||||
case "$1" in
|
local -r filedirname=$(dirname -- "$1")
|
||||||
*.tar.bz2|*.tbz|*.tbz2) tar "x${verbose}jf" "$1" -C "$filedirname/$targetdirname" ;;
|
# shellcheck disable=SC2001 # we don't depend on `extglob`...
|
||||||
*.tar.gz|*.tgz) tar "x${verbose}zf" "$1" -C "$filedirname/$targetdirname" ;;
|
targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< "$filename")
|
||||||
*.tar.xz|*.txz) tar "x${verbose}Jf" "$1" -C "$filedirname/$targetdirname" ;;
|
if [[ "$filename" == "$targetdirname" ]]; then
|
||||||
*.tar.Z) tar "x${verbose}Zf" "$1" -C "$filedirname/$targetdirname" ;;
|
# archive type either not supported or it doesn't need dir creation
|
||||||
*.bz2) bunzip2 "$1" ;;
|
targetdirname=""
|
||||||
*.deb) dpkg-deb -x${verbose} "$1" "${1:0:-4}" ;;
|
else
|
||||||
*.pax.gz) gunzip "$1"; set -- "$@" "${1:0:-3}" ;;
|
mkdir -v "$filedirname/$targetdirname"
|
||||||
*.gz) gunzip "$1" ;;
|
fi
|
||||||
*.pax) pax -r -f "$1" ;;
|
|
||||||
*.pkg) pkgutil --expand "$1" "${1:0:-4}" ;;
|
|
||||||
*.rar) unrar x "$1" ;;
|
|
||||||
*.rpm) rpm2cpio "$1" | cpio -idm${verbose} ;;
|
|
||||||
*.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;;
|
|
||||||
*.xz) xz --decompress "$1" ;;
|
|
||||||
*.zip|*.war|*.jar|*.nupkg) unzip "$1" -d "$filedirname/$targetdirname" ;;
|
|
||||||
*.Z) uncompress "$1" ;;
|
|
||||||
*.7z) 7za x -o"$filedirname/$targetdirname" "$1" ;;
|
|
||||||
*) echo "'$1' cannot be extracted via extract" >&2;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
shift
|
if [[ -f "$1" ]]; then
|
||||||
done
|
case "$1" in
|
||||||
|
*.tar.bz2 | *.tbz | *.tbz2) tar "x${verbose}jf" "$1" -C "$filedirname/$targetdirname" ;;
|
||||||
|
*.tar.gz | *.tgz) tar "x${verbose}zf" "$1" -C "$filedirname/$targetdirname" ;;
|
||||||
|
*.tar.xz | *.txz) tar "x${verbose}Jf" "$1" -C "$filedirname/$targetdirname" ;;
|
||||||
|
*.tar.Z) tar "x${verbose}Zf" "$1" -C "$filedirname/$targetdirname" ;;
|
||||||
|
*.bz2) bunzip2 "$1" ;;
|
||||||
|
*.deb) dpkg-deb -x"${verbose}" "$1" "${1:0:-4}" ;;
|
||||||
|
*.pax.gz)
|
||||||
|
gunzip "$1"
|
||||||
|
set -- "$@" "${1:0:-3}"
|
||||||
|
;;
|
||||||
|
*.gz) gunzip "$1" ;;
|
||||||
|
*.pax) pax -r -f "$1" ;;
|
||||||
|
*.pkg) pkgutil --expand "$1" "${1:0:-4}" ;;
|
||||||
|
*.rar) unrar x "$1" ;;
|
||||||
|
*.rpm) rpm2cpio "$1" | cpio -idm"${verbose}" ;;
|
||||||
|
*.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;;
|
||||||
|
*.xz) xz --decompress "$1" ;;
|
||||||
|
*.zip | *.war | *.jar | *.nupkg) unzip "$1" -d "$filedirname/$targetdirname" ;;
|
||||||
|
*.Z) uncompress "$1" ;;
|
||||||
|
*.7z) 7za x -o"$filedirname/$targetdirname" "$1" ;;
|
||||||
|
*) echo "'$1' cannot be extracted via extract" >&2 ;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Shorten extract
|
||||||
|
alias xt='extract'
|
||||||
|
|
|
||||||
|
|
@ -10,3 +10,6 @@ completion system
|
||||||
|
|
||||||
# aliases
|
# aliases
|
||||||
aliases general
|
aliases general
|
||||||
|
aliases bash-it
|
||||||
|
aliases directory
|
||||||
|
aliases editor
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue