aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--bash/bashrc.d/aliases.bash4
-rw-r--r--bash/bashrc.d/ed.bash11
3 files changed, 12 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 8fa14308..fd1a4ef1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@ bash/bashrc.d/*
!bash/bashrc.d/aliases.bash
!bash/bashrc.d/cd.bash
!bash/bashrc.d/completion.bash
+!bash/bashrc.d/ed.bash
!bash/bashrc.d/grep.bash
!bash/bashrc.d/ls.bash
!bash/bashrc.d/options.bash
diff --git a/bash/bashrc.d/aliases.bash b/bash/bashrc.d/aliases.bash
index 53b49e69..31296b7c 100644
--- a/bash/bashrc.d/aliases.bash
+++ b/bash/bashrc.d/aliases.bash
@@ -1,10 +1,6 @@
# Use a unified format for diff by default
alias diff='diff -u'
-# Add a colon prompt to ed when a command is expected rather than text; makes
-# it feel a lot more like using ex
-alias ed='ed -p:'
-
# Don't print the GDB copyright message on every invocation
alias gdb='gdb -q'
diff --git a/bash/bashrc.d/ed.bash b/bash/bashrc.d/ed.bash
new file mode 100644
index 00000000..d4d92158
--- /dev/null
+++ b/bash/bashrc.d/ed.bash
@@ -0,0 +1,11 @@
+# Add a colon prompt to ed when a command is expected rather than text; makes
+# it feel a lot more like using ex. Only do this when stdin is a terminal,
+# however.
+ed() {
+ if [[ -t 0 ]]; then
+ command ed -p: "$@"
+ else
+ command ed "$@"
+ fi
+}
+