aboutsummaryrefslogtreecommitdiffstats
path: root/.functions
diff options
context:
space:
mode:
authorMathias Bynens <mathias@qiwi.be>2013-03-26 15:22:58 +0100
committerMathias Bynens <mathias@qiwi.be>2013-03-26 15:22:58 +0100
commit7e824c8dd7010e558f319f73a7ffaf76f95a410f (patch)
treea8336c2586e279f81e844f043387dc352f20c9a5 /.functions
parent89274254b53bc1ad4931d1ccc70bbca4aea4166a (diff)
downloaddotfiles-7e824c8dd7010e558f319f73a7ffaf76f95a410f.tar.gz
dotfiles-7e824c8dd7010e558f319f73a7ffaf76f95a410f.tar.bz2
dotfiles-7e824c8dd7010e558f319f73a7ffaf76f95a410f.zip
.functions: Print trailing newlines when not piping the output
Diffstat (limited to '.functions')
-rw-r--r--.functions15
1 files changed, 12 insertions, 3 deletions
diff --git a/.functions b/.functions
index 6b0857f..90373ae 100644
--- a/.functions
+++ b/.functions
@@ -103,19 +103,28 @@ function digga() {
# Escape UTF-8 characters into their 3-byte format
function escape() {
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u)
- echo # newline
+ # print a newline unless we’re piping the output to another program
+ if [ -t 1 ]; then
+ echo # newline
+ fi
}
# Decode \x{ABCD}-style Unicode escape sequences
function unidecode() {
perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
- echo # newline
+ # print a newline unless we’re piping the output to another program
+ if [ -t 1 ]; then
+ echo # newline
+ fi
}
# Get a character’s Unicode code point
function codepoint() {
perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))"
- echo # newline
+ # print a newline unless we’re piping the output to another program
+ if [ -t 1 ]; then
+ echo # newline
+ fi
}
# Show all the names (CNs and SANs) listed in the SSL certificate