summaryrefslogtreecommitdiff
path: root/.config/bash/rc.d/10_aliases.sh
diff options
context:
space:
mode:
Diffstat (limited to '.config/bash/rc.d/10_aliases.sh')
-rw-r--r--.config/bash/rc.d/10_aliases.sh111
1 files changed, 111 insertions, 0 deletions
diff --git a/.config/bash/rc.d/10_aliases.sh b/.config/bash/rc.d/10_aliases.sh
new file mode 100644
index 0000000..758c069
--- /dev/null
+++ b/.config/bash/rc.d/10_aliases.sh
@@ -0,0 +1,111 @@
+#!/hint/bash
+
+######################################################################
+# Set up colors and settings for all the things #
+######################################################################
+if [ -x "`which dircolors`" ]; then
+ eval "$(dircolors -p | cat - "${XDG_CONFIG_HOME}/dir_colors" |
+ dircolors -b -)"
+ alias ls='ls -1v --color=auto'
+ alias dir='dir -v --color=auto'
+ alias vdir='vdir -v --color=auto'
+
+ for xgrep in ${PATH//:/\/*grep }/*grep; do
+ if [ -f "$xgrep" ]; then
+ xgrep=$(basename "$xgrep")
+ if [ "$xgrep" != pgrep ]; then
+ alias $xgrep="$xgrep --color=auto"
+ fi
+ fi
+ done
+ unset xgrep
+
+ wdiff() {
+ if [[ -t 1 ]]; then
+ local red="$(tput setaf 1)"
+ local blue="$(tput setaf 4)"
+ local bold="$(tput bold)"
+ local reset="$(tput sgr0)"
+ command wdiff \
+ -w "$bold$red[-" \
+ -x "-]$reset" \
+ -y "$bold$blue{+" \
+ -z "+}$reset" "$@"
+ else
+ command wdiff "$@"
+ fi
+ }
+
+ diff() {
+ if [[ -t 1 ]]; then
+ (
+ set -o pipefail
+ command diff "$@" | colordiff
+ )
+ else
+ command diff "$@"
+ fi
+ }
+else
+ alias ls='ls -1v'
+ alias dir='dir -v'
+ alias vdir='vdir -v'
+fi
+
+######################################################################
+# Set up the standard aliases for ls #
+######################################################################
+alias ll='ls -l'
+alias la='ls -a'
+alias l='ls -CF'
+
+######################################################################
+# Some preferences for miscellaneous stuff #
+######################################################################
+#alias rm='gvfs-trash'
+#alias sed='sed --follow-symlinks' # breaks operating on stdio in GNU sed 4.2.2
+alias tree='tree --charset utf8'
+alias cd=pushd
+alias gitk='gitk --all --date-order'
+alias userctl='systemctl --user'
+
+######################################################################
+# These are actually functions :P #
+######################################################################
+term-title() {
+ local fmt=''
+ case "$TERM" in
+ screen|tmux) fmt='\ek%s\e\\';;
+ xterm*|rxvt*) fmt='\e]0;%s\a';;
+ esac
+ printf "$fmt" "$*"
+}
+mvln() {
+ if [[ ! -L "$1" ]]; then
+ libremessages error 'Not a soft link: %s' "$1"
+ fi
+ target=$(readlink -f -- "$1")
+ ln -srT -- "$target" "$2"
+ if cmp -- "$1" "$2"; then
+ rm -f -- "$1"
+ else
+ libremessages error 'Failed moving link: %s -> %s' "$1" "$2"
+ fi
+}
+jarls() {
+ jar tf "$1" |
+ sed -n 's/\.class$//p' |
+ LC_ALL=C sort |
+ xargs -r -d $'\n' javap -classpath "$1"
+}
+tarls() {
+ local file
+ for file in "$@"; do
+ bsdtar tf "$file" | sed "s|^|$file:|"
+ done
+}
+jarmain() {
+ jarls "$1" 2>/dev/null |
+ grep -E '(^[a-z]|public static void main\(java\.lang\.String\[\]\))' |
+ grep -B1 '^ '
+}