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 source-path=SCRIPTDIR
|
||||
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'
|
||||
|
||||
# Shortcuts to edit startup files
|
||||
alias vbrc='${VISUAL:-vim} ~/.bashrc'
|
||||
alias vbpf='${VISUAL:-vim} ~/.bash_profile'
|
||||
|
||||
# colored grep
|
||||
# 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
|
||||
|
|
@ -34,12 +18,11 @@ fi
|
|||
alias c='clear'
|
||||
alias cls='clear'
|
||||
|
||||
alias edit='${EDITOR:-${ALTERNATE_EDITOR?}}'
|
||||
alias pager='${PAGER:=less}'
|
||||
alias pager='${PAGER:-less}'
|
||||
|
||||
alias q='exit'
|
||||
|
||||
alias irc='${IRC_CLIENT:=irc}'
|
||||
alias irc='${IRC_CLIENT:-irc}'
|
||||
|
||||
# Language aliases
|
||||
alias rb='ruby'
|
||||
|
|
@ -47,14 +30,9 @@ alias py='python'
|
|||
alias ipy='ipython'
|
||||
|
||||
# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/
|
||||
|
||||
alias piano='pianobar'
|
||||
|
||||
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
|
||||
if _command_exists pianobar; then
|
||||
alias piano='pianobar'
|
||||
fi
|
||||
|
||||
# Shell History
|
||||
alias h='history'
|
||||
|
|
@ -64,17 +42,6 @@ if ! _command_exists tree; then
|
|||
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
|
||||
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
|
||||
function catt() {
|
||||
for i in "$@"; do
|
||||
|
|
@ -92,5 +59,6 @@ function catt() {
|
|||
# aliases and enable just the ones for Bash-it explicitly:
|
||||
# bash-it disable alias general
|
||||
# bash-it enable alias bash-it
|
||||
# shellcheck source-path=SCRIPTDIR
|
||||
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
|
||||
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
|
||||
# https://stackoverflow.com/a/4687513
|
||||
alias vimh='vim -c ":h | only"'
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ plugins/available/colors.plugin.bash
|
|||
plugins/available/direnv.plugin.bash
|
||||
plugins/available/dirs.plugin.bash
|
||||
plugins/available/docker-machine.plugin.bash
|
||||
plugins/available/extract.plugin.bash
|
||||
plugins/available/gif.plugin.bash
|
||||
plugins/available/git-subrepo.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...'
|
||||
|
||||
# extract file(s) from compressed status
|
||||
extract() {
|
||||
local opt
|
||||
local OPTIND=1
|
||||
while getopts "hv" opt; do
|
||||
case "$opt" in
|
||||
h)
|
||||
cat <<End-Of-Usage
|
||||
function extract() {
|
||||
local opt OPTIND=1 verbose
|
||||
local filename filedirname targetdirname
|
||||
while getopts "hv" opt; do
|
||||
case "$opt" in
|
||||
h)
|
||||
cat << EOU
|
||||
Usage: ${FUNCNAME[0]} [option] <archives>
|
||||
options:
|
||||
-h show this message and exit
|
||||
-v verbosely list files processed
|
||||
End-Of-Usage
|
||||
return
|
||||
;;
|
||||
v)
|
||||
local -r verbose='v'
|
||||
;;
|
||||
?)
|
||||
extract -h >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
EOU
|
||||
return
|
||||
;;
|
||||
v)
|
||||
local -r verbose='v'
|
||||
;;
|
||||
?)
|
||||
extract -h >&2
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
[ $# -eq 0 ] && extract -h && return 1
|
||||
while [ $# -gt 0 ]; do
|
||||
if [[ ! -f "$1" ]]; then
|
||||
echo "extract: '$1' is not a valid file" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
if [[ $# -eq 0 ]]; then
|
||||
extract -h
|
||||
return 1
|
||||
fi
|
||||
|
||||
local -r filename=$(basename -- $1)
|
||||
local -r filedirname=$(dirname -- $1)
|
||||
local targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< $filename)
|
||||
if [ "$filename" = "$targetdirname" ]; then
|
||||
# archive type either not supported or it doesn't need dir creation
|
||||
targetdirname=""
|
||||
else
|
||||
mkdir -v "$filedirname/$targetdirname"
|
||||
fi
|
||||
while [[ $# -gt 0 ]]; do
|
||||
if [[ ! -f "${1:-}" ]]; then
|
||||
echo "extract: '$1' is not a valid file" >&2
|
||||
shift
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ -f "$1" ]; then
|
||||
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
|
||||
local -r filename=$(basename -- "$1")
|
||||
local -r filedirname=$(dirname -- "$1")
|
||||
# shellcheck disable=SC2001 # we don't depend on `extglob`...
|
||||
targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< "$filename")
|
||||
if [[ "$filename" == "$targetdirname" ]]; then
|
||||
# archive type either not supported or it doesn't need dir creation
|
||||
targetdirname=""
|
||||
else
|
||||
mkdir -v "$filedirname/$targetdirname"
|
||||
fi
|
||||
|
||||
shift
|
||||
done
|
||||
if [[ -f "$1" ]]; then
|
||||
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 general
|
||||
aliases bash-it
|
||||
aliases directory
|
||||
aliases editor
|
||||
|
|
|
|||
Loading…
Reference in New Issue