906
Comment: add rsync
|
942
Reverting my change since there's more than one occurrence of '\e'. Instead, added note at bottom about substituting '\x1b'.
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
== How can I see a progress bar when copying/moving files? == You can't with `cp(1)`, but you can either: * build one yourself with tools such as [[http://www.ivarch.com/programs/pv.shtml|pv]] or [[http://clpbar.sourceforge.net/|clpbar]]; * use some other tool, e.g. [[http://members.iinet.net.au/~lynx/vcp/|vcp]]. You may want to use pv(1) since it's packaged for many systems. In that case, it's convenient if you create a function or script to wrap it. For example: |
== How can I set the contents of my terminal's title bar? == If you have a terminal that understands `xterm`-compatible escape sequences, and you just want to set the title one time, you can use a function like this: |
Line 13: | Line 6: |
pv "$1" > "$2/${1##*/}" | settitle() { printf '\e]2;%s\a' "$*"; } |
Line 16: | Line 9: |
This lacks error checking and support for moving files. you can also use the rsync: |
If you want to set the title bar to the currently-running command line every time you type a command, then this solution approximates it: |
Line 21: | Line 12: |
rsync -avx --progress --stats "$1" "$2" | trap 'printf "\e]2;%s\a" "$(HISTTIMEFORMAT='' history 1)" > /dev/tty' DEBUG |
Line 24: | Line 15: |
Please note that the "total" of files can change each time rsync enter a directory and finds more/less files that it expected, but at least is more info than cp. Rsync progress is good for big transfers with small files. | However, it leaves the command history number in place, and it doesn't trigger on explicit subshells like `(cd foo && make)`. Or to use just the name and arguments of the current simple command: {{{ trap 'printf "\e]2;%s\a" "$BASH_COMMAND" > /dev/tty' DEBUG }}} For Posix-compliant shells which don't recognize '\e' as a character sequence to be interpreted as `Escape`, '\x1b' may be substituted instead. |
How can I set the contents of my terminal's title bar?
If you have a terminal that understands xterm-compatible escape sequences, and you just want to set the title one time, you can use a function like this:
settitle() { printf '\e]2;%s\a' "$*"; }
If you want to set the title bar to the currently-running command line every time you type a command, then this solution approximates it:
trap 'printf "\e]2;%s\a" "$(HISTTIMEFORMAT='' history 1)" > /dev/tty' DEBUG
However, it leaves the command history number in place, and it doesn't trigger on explicit subshells like (cd foo && make).
Or to use just the name and arguments of the current simple command:
trap 'printf "\e]2;%s\a" "$BASH_COMMAND" > /dev/tty' DEBUG
For Posix-compliant shells which don't recognize '\e' as a character sequence to be interpreted as Escape, '\x1b' may be substituted instead.