Skip to content

Commit 8b5a8d4

Browse files
authored
Merge pull request #2095 from gaelicWizard/alias/general
better add in the good rather than wait for the GOAT.
2 parents da80656 + 559769c commit 8b5a8d4

File tree

6 files changed

+69
-31
lines changed

6 files changed

+69
-31
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# shellcheck shell=bash
2+
about-alias 'Shortcuts for directory commands: ls, cd, &c.'
3+
4+
if command ls --color -d . &> /dev/null; then
5+
alias ls='ls --color=auto'
6+
# BSD `ls` doesn't need an argument (`-G`) when `$CLICOLOR` is set.
7+
fi
8+
9+
# List directory contents
10+
alias sl=ls
11+
alias la='ls -AF' # Compact view, show hidden
12+
alias ll='ls -Al'
13+
alias l='ls -A'
14+
alias l1='ls -1'
15+
alias lf='ls -F'
16+
17+
# Change directory
18+
alias ..='cd ..' # Go up one directory
19+
alias cd..='cd ..' # Common misspelling for going up one directory
20+
alias ...='cd ../..' # Go up two directories
21+
alias ....='cd ../../..' # Go up three directories
22+
alias -- -='cd -' # Go back
23+
24+
# Create or remove directory
25+
alias md='mkdir -p'
26+
alias rd='rmdir'

aliases/available/editor.aliases.bash

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# shellcheck shell=bash
2+
about-alias 'shortcuts for editing'
3+
4+
alias edit='${EDITOR:-${ALTERNATE_EDITOR:-nano}}'
5+
alias e='edit'
6+
7+
# sudo editors
8+
alias svim='sudo ${VISUAL:-vim}'
9+
alias snano='sudo ${ALTERNATE_EDITOR:-nano}'
10+
alias sedit='sudo ${EDITOR:-${ALTERNATE_EDITOR:-nano}}'
11+
12+
# Shortcuts to edit startup files
13+
alias vbrc='${VISUAL:-vim} ~/.bashrc'
14+
alias vbpf='${VISUAL:-vim} ~/.bash_profile'

aliases/available/general.aliases.bash

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
# shellcheck shell=bash
2+
# shellcheck source-path=SCRIPTDIR
23
about-alias 'general aliases'
34

4-
if command ls --color -d . &> /dev/null; then
5-
alias ls='ls --color=auto'
6-
# BSD `ls` doesn't need an argument (`-G`) when `$CLICOLOR` is set.
7-
fi
8-
9-
# List directory contents
10-
alias sl=ls
11-
alias la='ls -AF' # Compact view, show hidden
12-
alias ll='ls -al'
13-
alias l='ls -a'
14-
alias l1='ls -1'
15-
alias lf='ls -F'
16-
175
alias _='sudo'
186

19-
# Shortcuts to edit startup files
20-
alias vbrc='${VISUAL:-vim} ~/.bashrc'
21-
alias vbpf='${VISUAL:-vim} ~/.bash_profile'
22-
237
# colored grep
248
# Need to check an existing file for a pattern that will be found to ensure
259
# that the check works when on an OS that supports the color option
@@ -39,16 +23,17 @@ alias pager='${PAGER:=less}'
3923

4024
alias q='exit'
4125

42-
alias irc='${IRC_CLIENT:=irc}'
26+
alias irc='${IRC_CLIENT:-irc}'
4327

4428
# Language aliases
4529
alias rb='ruby'
4630
alias py='python'
4731
alias ipy='ipython'
4832

4933
# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/
50-
51-
alias piano='pianobar'
34+
if _command_exists pianobar; then
35+
alias piano='pianobar'
36+
fi
5237

5338
alias ..='cd ..' # Go up one directory
5439
alias cd..='cd ..' # Common misspelling for going up one directory
@@ -92,5 +77,6 @@ function catt() {
9277
# aliases and enable just the ones for Bash-it explicitly:
9378
# bash-it disable alias general
9479
# bash-it enable alias bash-it
95-
# shellcheck source-path=SCRIPTDIR
9680
source "$BASH_IT/aliases/available/bash-it.aliases.bash"
81+
source "$BASH_IT/aliases/available/directory.aliases.bash"
82+
source "$BASH_IT/aliases/available/editor.aliases.bash"

aliases/available/vim.aliases.bash

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# shellcheck shell=bash
22
about-alias 'vim abbreviations'
33

4-
_command_exists vim || return
4+
alias v='${VISUAL:-vim}'
55

6-
alias v='vim'
6+
if ! _command_exists vim; then
7+
_log_warning "Without 'vim', these aliases just aren't that useful..."
8+
fi
79
# open the vim help in fullscreen incorporated from
810
# https://stackoverflow.com/a/4687513
911
alias vimh='vim -c ":h | only"'

plugins/available/extract.plugin.bash

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ End-Of-Usage
2828
done
2929
shift $((OPTIND - 1))
3030

31-
[ $# -eq 0 ] && extract -h && return 1
32-
while [ $# -gt 0 ]; do
33-
if [[ ! -f "$1" ]]; then
31+
if [[ $# -eq 0 ]]; then
32+
extract -h
33+
return 1
34+
fi
35+
36+
while [[ $# -gt 0 ]]; do
37+
if [[ ! -f "${1:-}" ]]; then
3438
echo "extract: '$1' is not a valid file" >&2
3539
shift
3640
continue
@@ -39,23 +43,23 @@ End-Of-Usage
3943
local -r filename=$(basename -- "$1")
4044
local -r filedirname=$(dirname -- "$1")
4145
local targetdirname
42-
# shellcheck disable=SC2001
46+
# shellcheck disable=SC2001 # we don't depend on `extglob`...
4347
targetdirname=$(sed 's/\(\.tar\.bz2$\|\.tbz$\|\.tbz2$\|\.tar\.gz$\|\.tgz$\|\.tar$\|\.tar\.xz$\|\.txz$\|\.tar\.Z$\|\.7z$\|\.nupkg$\|\.zip$\|\.war$\|\.jar$\)//g' <<< "$filename")
44-
if [ "$filename" = "$targetdirname" ]; then
48+
if [[ "$filename" == "$targetdirname" ]]; then
4549
# archive type either not supported or it doesn't need dir creation
4650
targetdirname=""
4751
else
4852
mkdir -v "$filedirname/$targetdirname"
4953
fi
5054

51-
if [ -f "$1" ]; then
55+
if [[ -f "$1" ]]; then
5256
case "$1" in
5357
*.tar.bz2 | *.tbz | *.tbz2) tar "x${verbose}jf" "$1" -C "$filedirname/$targetdirname" ;;
5458
*.tar.gz | *.tgz) tar "x${verbose}zf" "$1" -C "$filedirname/$targetdirname" ;;
5559
*.tar.xz | *.txz) tar "x${verbose}Jf" "$1" -C "$filedirname/$targetdirname" ;;
5660
*.tar.Z) tar "x${verbose}Zf" "$1" -C "$filedirname/$targetdirname" ;;
5761
*.bz2) bunzip2 "$1" ;;
58-
*.deb) dpkg-deb "-x${verbose}" "$1" "${1:0:-4}" ;;
62+
*.deb) dpkg-deb -x"${verbose}" "$1" "${1:0:-4}" ;;
5963
*.pax.gz)
6064
gunzip "$1"
6165
set -- "$@" "${1:0:-3}"
@@ -64,7 +68,7 @@ End-Of-Usage
6468
*.pax) pax -r -f "$1" ;;
6569
*.pkg) pkgutil --expand "$1" "${1:0:-4}" ;;
6670
*.rar) unrar x "$1" ;;
67-
*.rpm) rpm2cpio "$1" | cpio "-idm${verbose}" ;;
71+
*.rpm) rpm2cpio "$1" | cpio -idm"${verbose}" ;;
6872
*.tar) tar "x${verbose}f" "$1" -C "$filedirname/$targetdirname" ;;
6973
*.xz) xz --decompress "$1" ;;
7074
*.zip | *.war | *.jar | *.nupkg) unzip "$1" -d "$filedirname/$targetdirname" ;;
@@ -77,3 +81,6 @@ End-Of-Usage
7781
shift
7882
done
7983
}
84+
85+
# Shorten extract
86+
alias xt='extract'

profiles/default.bash_it

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ completion system
1010

1111
# aliases
1212
aliases general
13+
aliases bash-it
14+
aliases directory
15+
aliases editor

0 commit comments

Comments
 (0)