From: Oleg Broytman Date: Tue, 21 Jan 2025 17:46:58 +0000 (+0300) Subject: .bashrc,.shellrc: Make more simple functions aliases X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=ed3f8518df4bfa0cce37b42c67fece1086b44de0;p=dotfiles.git .bashrc,.shellrc: Make more simple functions aliases --- diff --git a/.bashrc b/.bashrc index 3675eb4..ce4af33 100644 --- a/.bashrc +++ b/.bashrc @@ -59,7 +59,7 @@ shopt -s histappend [ "`type -t ls`" = alias ] && unalias ls [ "`type -t ll`" = alias ] && unalias ll -functions() { typeset -f "$@"; } +alias functions='typeset -f' if [ -r "$HOME"/admin/prog/bash_prompt ]; then . "$HOME"/admin/prog/bash_prompt @@ -192,26 +192,32 @@ fi if test -x /usr/bin/screen >/dev/null 2>&1; then - screen_newwin() { - history -a - screen "$@" - } + alias screen_newwin='history -a; screen' fi -if [ "$SHLVL" -eq 1 -a "`type -t X`" = function ] && which startx >/dev/null 2>&1; then - # From https://stackoverflow.com/a/18839557 +if [ "$SHLVL" -eq 1 ] && which startx >/dev/null 2>&1; then + case "`type -t X`" in + alias) + alias _non_bash_X="`alias X | sed -e \"s/^alias X='//\" -e \"s/'\$//\"`" + alias X='history -a; _non_bash_X; history -r' + ;; - copy_function() { - test -n "$(declare -f "$1")" || return - eval "${_/$1/$2}" - } + function) + # From https://stackoverflow.com/a/18839557 - rename_function() { - copy_function "$@" || return - unset -f "$1" - } + copy_function() { + test -n "$(declare -f "$1")" || return + eval "${_/$1/$2}" + } - rename_function X _non_bash_X + rename_function() { + copy_function "$@" || return + unset -f "$1" + } - X() { history -a; _non_bash_X; history -r; } + #rename_function X _non_bash_X + + #X() { history -a; _non_bash_X; history -r; } + ;; + esac fi diff --git a/.shellrc b/.shellrc index f5971ad..72c4a15 100644 --- a/.shellrc +++ b/.shellrc @@ -40,7 +40,7 @@ case "$HOME" in esac if test -n "$KSH_VERSION" -o -n "$FCEDIT"; then - back() { cd - "$@"; } + alias back='cd -' alias j=jobs fi @@ -212,7 +212,7 @@ vim() { if [ "$SHLVL" -eq 1 ] && which startx >/dev/null 2>&1; then - X() { startx >> .Xserver.log 2>&1; cyr; /bin/rm -f .Xauthority; } + alias X='startx >> .Xserver.log 2>&1; cyr; /bin/rm -f .Xauthority' fi alias x='logout || exit'