]> git.phdru.name Git - dotfiles.git/commitdiff
.bashrc,.shellrc: Make more simple functions aliases
authorOleg Broytman <phd@phdru.name>
Tue, 21 Jan 2025 17:46:58 +0000 (20:46 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 21 Jan 2025 17:46:58 +0000 (20:46 +0300)
.bashrc
.shellrc

diff --git a/.bashrc b/.bashrc
index 3675eb41e28cfedd110290406ccfb001edf1ab02..ce4af336cd1f7ab42a30e2f999b0291a15aed7f0 100644 (file)
--- 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
index f5971adb03cc8faae50faa7c7747050d9c94f95d..72c4a158f0fd434614bf0156a2b41f1a5d772908 100644 (file)
--- 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'