Tired of not finding things in your terminal because there's a lot of logs and garbage? Tired of destroying the Enter key by creating a "void zone" in your terminal so that you can see the error that you're trying to debug?
Indeed, printf is shorter. I use it in a similar fashion in my own script [1], which can be made to behave like hr() (haven't tried shells other than bash):
If you want to conform to ANSI, just use two dashes (--) or ASCII, the box drawing character, the source of the unicode variant. This is important because it remains the primary font in the core of any EGA and VGA-compatible graphics card (basically all graphics cards).
is just evil. That's a great way to own a machine. You can even read the code today, but run the command tomorrow when someone had replaced the code with a giant exploit. Not saying there is a better way to distribute something like this that is as easy to use, but damn, this is just asking for trouble.
Run the command, then look through the local copy to make sure it's safe. Once you have downloaded the code, there's no way that the project owner could change your copy.
A benefit of this is you can also use it in your node programs (and clientside JS if you use something like browserify.)
And like any software you install that doesn't run in a sandbox, you should look at the source before running it or have some other reason for trusting it. (I briefly thought about how ironic it would be to have this program do something evil, but decided against it.)
I know that, I did not want to be evil writing that in the instructions but that's the best way to copy that file, also this is a file to be executable, so even if you use wget you are asking for trouble, downloading a file to your $PATH and making it executable, do you have any idea on how to improve the instructions?
When are these comments going to stop? Everyone lazy enough is going to keep suggesting "curl install" and everyone lazy enough is going to keep using it, and everyone that has something worth protecting and cares enough is either not going to use it or is going to audit it anyway, and comments like this aren't going to move anyone between those camps.
If you all think "curl install" is so evil then build something secure to replace it. It's got to be as easy from a "package maintainer" as well as a user's perspective, and you have to figure out some way to validate security. But until then, warning people that they should read code they execute is a waste of bandwidth.
This has me wondering, why haven't terminal windows evolved functionally to better support history, scrollback buffers jumping or markers, selection with a mouse, auto-complete hints, etc. Instead we're limited to hacks like this or the screenshot at http://unix.stackexchange.com/questions/3650/would-it-be-pos... ... and no, I don't think "use emacs" is an acceptable answer ;-)
Oh and instead of adding blank lines with "Enter", I often just type "clear" and hit return. Bingo, tons of whitespace now added.
I've often wondered if there is a terminal which supported the "jump to previous input" functionality described in the stackexchange question but I've never seen anything better than what is mentioned in the answers. I've heard Plan 9's Rio supported something like this but searching around, I can't see any mention of it.
Or a colored prompt with a timestamp and hostname, great with a huge scrollback.
PS1='\[\033[1;32m\](\A) <\h> [$PWD \$ \[\033[m\]'
Edit: Using tmux with a 200,000 line scrollback, you can also search scrollback based on the hour in which you ran the command. A search for "(12:" would put you right in the ball park.
I like to use terminal colors so it's red, as well as allowing controlling width, but defaulting to terminal width.
$ cat ~/bin/br
#!/bin/sh
if [ "$1" == "" ] ; then
COLS=`tput cols`
elif [ "$1" == "--help" ] ; then
echo "$0: Prints a red line across the screen. or $0 <##> for a specific width."
echo "$0: br ; grep -ir foo * -- place a marker to see where results begin / end."
echo "$0: br 80 ; cat file -- use to check for overly long lines."
exit
else
COLS=$1
fi
LINE=""
for (( x=0 ; x<$COLS ; x++ )); do LINE="$LINE-" ; done
echo -e '\E[47;0m'"\033[1m$LINE\033[0m"
I'm interested why they use "seq"? [seq can take a single value too apparently, perhaps they did half width rulers with "seq 2 $(tputs cols)"?]
Why doesn't
!/bin/bash
j=$(tput cols); for i in {1..$j}; do echo -n "#";done
work, presumably there's some escape that needs doing?
The alternative:
!/bin/bash
for (( c=1 ; c<=$COLUMNS; c++ )); do echo -n "#";done
seems fine?
Also BASH has $COLUMNS builtin FWIW, though portability explains use of tput.
I like it, should be a standard command, including options to specify width as a proportion and to add whitespace lines. Code for this must be in almost every shell script.
Both of those would work in bash, but they're non-standard extensions. The seq construction would work in any POSIX shell, though the seq command itself is still non-standard I think.
Thanks! This is actually what I love doing, small utilities to help me and others which are not that fancy but get the work done and are compatible with my workflow.
[+] [-] ehamberg|12 years ago|reply
[+] [-] ppurka|12 years ago|reply
[+] [-] chjj|12 years ago|reply
edit: Could also use tput instead of $COLUMNS. Sometimes the $COLUMNS may not always be updated (bash's checkwinsize option).
[+] [-] thekaleb|12 years ago|reply
[+] [-] Fasebook|12 years ago|reply
[+] [-] IgorPartola|12 years ago|reply
[+] [-] bodyfour|12 years ago|reply
I guarantee you that it'd be easier to hide something nefarious in 3000 lines of autoconf boilerplate.
[+] [-] Crito|12 years ago|reply
[+] [-] timmclean|12 years ago|reply
[+] [-] jaredsohn|12 years ago|reply
http://www.github.com/jaredsohn/hr
Install it via 'npm -g install hr'.
A benefit of this is you can also use it in your node programs (and clientside JS if you use something like browserify.)
And like any software you install that doesn't run in a sandbox, you should look at the source before running it or have some other reason for trusting it. (I briefly thought about how ironic it would be to have this program do something evil, but decided against it.)
[+] [-] C0d3r|12 years ago|reply
[+] [-] vezzy-fnord|12 years ago|reply
[+] [-] leif|12 years ago|reply
If you all think "curl install" is so evil then build something secure to replace it. It's got to be as easy from a "package maintainer" as well as a user's perspective, and you have to figure out some way to validate security. But until then, warning people that they should read code they execute is a waste of bandwidth.
[+] [-] lstamour|12 years ago|reply
Oh and instead of adding blank lines with "Enter", I often just type "clear" and hit return. Bingo, tons of whitespace now added.
[+] [-] gnachman|12 years ago|reply
More info about the general idea of integrating the terminal with the shell, including command history: http://www.iterm2.com/shell_integration.html
I expect FinalTerm will do something along the lines of marks as well, and has introduced some cool ideas with history.
Of course, iTerm2 has has had autocomplete for years.
If you'd like a shinier <hr> in iTerm2, you could use this script:
#!/bin/bash # usage: hr image.png printf '\033]1337;File=inline=1;width='`tput cols`';height=8px;preserveAspectRatio=0:' base64 < $1 printf '\007'
[+] [-] datr|12 years ago|reply
[+] [-] tgrochowicz|12 years ago|reply
$ dong 8=================================D # Till the end of your terminal window $
https://github.com/tgrochowicz/hr
[+] [-] rm445|12 years ago|reply
[+] [-] jsonau|12 years ago|reply
[+] [-] loopj|12 years ago|reply
[+] [-] C0d3r|12 years ago|reply
[+] [-] comex|12 years ago|reply
――――――――――――――――――――――――――――――――――――――――――――――――――
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅┅
██████████████████████████████████████████████████
[+] [-] C0d3r|12 years ago|reply
But if you really want another character by default, you can do this:
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] Aardwolf|12 years ago|reply
PS1="\[\033[0;31m\][\u@\h:\w]$\[\033[0m\]"
[+] [-] wylee|12 years ago|reply
[+] [-] jethro_tell|12 years ago|reply
PS1='\[\033[1;32m\](\A) <\h> [$PWD \$ \[\033[m\]'
Edit: Using tmux with a 200,000 line scrollback, you can also search scrollback based on the hour in which you ran the command. A search for "(12:" would put you right in the ball park.
[+] [-] jamestomasino|12 years ago|reply
[+] [-] ramses0|12 years ago|reply
[+] [-] pbhjpbhj|12 years ago|reply
Why doesn't
work, presumably there's some escape that needs doing?The alternative:
seems fine?Also BASH has $COLUMNS builtin FWIW, though portability explains use of tput.
I like it, should be a standard command, including options to specify width as a proportion and to add whitespace lines. Code for this must be in almost every shell script.
[+] [-] pdw|12 years ago|reply
[+] [-] yoha|12 years ago|reply
[+] [-] antimora|12 years ago|reply
[+] [-] sp332|12 years ago|reply
[+] [-] azinman2|12 years ago|reply
[+] [-] gamacodre|12 years ago|reply
[+] [-] num|12 years ago|reply
[+] [-] codegeek|12 years ago|reply
[+] [-] C0d3r|12 years ago|reply
[+] [-] chrisamiller|12 years ago|reply
[+] [-] nagrom|12 years ago|reply
[+] [-] Ujio|12 years ago|reply
[+] [-] rcfox|12 years ago|reply
[+] [-] C0d3r|12 years ago|reply
vim ~/.gitconfig
[+] [-] abruzzi|12 years ago|reply
[+] [-] C0d3r|12 years ago|reply
[+] [-] jaredsohn|12 years ago|reply
[+] [-] C0d3r|12 years ago|reply
[+] [-] unknown|12 years ago|reply
[deleted]
[+] [-] KiwiCoder|12 years ago|reply