Skip to content

Commit

Permalink
aliases/general: minor fixes
Browse files Browse the repository at this point in the history
- Don't define some aliases if the target isn't installed, use _command_exists to check instead of `type` and `which`.
- Use `$EDITOR` for the editor for aliases about editing, excep the `sudo` ones because maybe you want those specifically?
- Fix `ls` aliases to match their common definitions (-A instead of -a: don't show '.' and '..' when displaying hidden files).
  • Loading branch information
gaelicWizard committed Sep 9, 2021
1 parent 0b80d0b commit a31f3fc
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions aliases/available/general.aliases.bash
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ fi
# List directory contents
alias sl=ls
alias la='ls -AF' # Compact view, show hidden
alias ll='ls -al'
alias l='ls -a'
alias ll='ls -Al'
alias l='ls -A'
alias l1='ls -1'

alias _="sudo"

# Shortcuts to edit startup files
alias vbrc="vim ~/.bashrc"
alias vbpf="vim ~/.bash_profile"
alias vbrc='${EDITOR:-vim} ~/.bashrc'
alias vbpf='${EDITOR:-vim} ~/.bash_profile'

# colored grep
# Need to check an existing file for a pattern that will be found to ensure
Expand All @@ -30,10 +30,8 @@ then
alias grep='grep --color=auto'
fi

if which gshuf &> /dev/null
then
alias shuf=gshuf
fi
_command_exists gshuf \
&& alias shuf=gshuf

alias c='clear'
alias k='clear'
Expand All @@ -52,8 +50,8 @@ alias py='python'
alias ipy='ipython'

# Pianobar can be found here: http://github.com/PromyLOPh/pianobar/

alias piano='pianobar'
_command_exists pianobar \
&& alias piano='pianobar'

alias ..='cd ..' # Go up one directory
alias cd..='cd ..' # Common misspelling for going up one directory
Expand All @@ -65,17 +63,16 @@ alias -- -='cd -' # Go back
alias h='history'

# Tree
if [ ! -x "$(which tree 2>/dev/null)" ]
then
alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"
fi
_command_exists tree \
|| alias tree="find . -print | sed -e 's;[^/]*/;|____;g;s;____|; |;g'"

# Directory
alias md='mkdir -p'
alias rd='rmdir'

# Shorten extract
alias xt="extract"
_command_exists 'extract' \
&& alias xt="extract"

# sudo editors
alias svim="sudo vim"
Expand Down

0 comments on commit a31f3fc

Please sign in to comment.