Skip to content

Instantly share code, notes, and snippets.

@Omie
Created January 16, 2019 03:47
Show Gist options
  • Save Omie/aa79990e72d580e211a2a78c1b545630 to your computer and use it in GitHub Desktop.
Save Omie/aa79990e72d580e211a2a78c1b545630 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "Magic!" echo -en "\033[1F\033[2K" echo "Moar Magic!"
#This script will print "Magic!" then the next echo sends escape sequences that move the cursor up 1 line with '\033[1F', then '\033[2K' clears the line the cursor is on, which is now the "Magic!" line. Then we output "Moar Magic". 3 commands but only one line of output.
#The -e option on echo enables the escape sequences instead of literal chars. -n disables echos automatic newline for the sequence that deletes the first line
# https://news.ycombinator.com/item?id=18915489
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment