news on my phone

Firefox Focus

I tried Firefox Focus a few years before the pandemic when I was testing Android browsers for digital signage. Focus didn’t meet my needs at the time and I moved on. (I ended up using Fully Kiosk Browser. Eventually left Android for Screenly OSE)

Fast forward to now. Most of my screen time is on my phone during my commute and break. The news sites I like to visit are almost unreadable on my phone, due to excessive ads. Google Chrome doesn’t accommodate extensions. A search on ad blocking Android brought me to Focus. I find Focus fast, efficient at blocking ads, and fun to use.

Also available for iOS.

a screen grab of Firefox Focus

articles on neurology/psychology that I like

terminal window title

The following is a rewrite of change gnome terminal title after some experimentation and exploration. Applicable to xterm*, rxvt*, GNOME Terminal, likely others.

change the terminal title
scroll down or read through for code you can copy and paste.

problem

When I open a terminal window, the title is Terminal. When I ssh into another host, the title changes to me@somehost: mypath. When I close the session, the window title is still me@somehost: mypath.

first solution

Addresses the issue, not the cause, by changing the title back.

$ cat `which ctt`
#!/bin/bash
echo -ne "\e]0;${*:-Terminal}\a"

No arguments sets the title to Terminal. Otherwise the title is set to the arguments.

Links with more information:
https://tldp.org/HOWTO/Xterm-Title.html
and especially
https://tldp.org/HOWTO/Xterm-Title-3.html
Less helpful Stackexchange link
https://unix.stackexchange.com/questions/177572/how-to-rename-terminal-tab-title-in-gnome-terminal

perhaps better

The remote host has a case "$TERM" in .bashrc setting the prompt to one that will change the terminal title. My .bashrc does not, either due to operator error, or perhaps a faulty gpg-agent package install script clobbered it. Copy /etc/skel/.bashrc to your $HOME. If you already have a .bashrc you want to keep, prepend the contents of /etc/skel/.bashrc.

This /etc/skel/.bashrc is found on Debian and Debian derived distributions. Your mileage may vary.

Here are the lines that set the title:

$ grep -A4 -B3 ]0 /etc/skel/.bashrc
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

note

You can’t have your cake and eat it too. If you set your .bashrc to change the title with every prompt, the title you set with the first solution will be overwritten by the next prompt, before you can see it.

you can have it both ways

Define a function in the current shell, so $PS1 in that shell can be accessed. $PS1 will reset the title without user action, once the title has been set.

$ cat ctt
ctt() {
    # default
    title=${*:-'\u@\h: \w'}
    # save prompt part
    prompt_part=${PS1##*'\a\]'}
    PS1='\[\e]0;${debian_chroot:+($debian_chroot)}'${title}'\a\]'${prompt_part}
}

Add to your .bashrc, or test by copying and pasting the function at the prompt or pasting into a file and sourceing that file

. ctt

and run the function.

ctt My Fancy Terminal Title

what is ${debian_chroot:+($debian_chroot)}?

start with

? grep debian_chroot ~/.bashrc
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"

also, take a look at: https://wiki.debian.org/chroot

${debian_chroot:+($debian_chroot)} means wrap the value of $debian_chroot with parenthesis if set and not null, otherwise, do nothing.

If you have ${debian_chroot:+($debian_chroot)} in your $PS1, do try:

$ debian_chroot="change my prompt"
(change my prompt)$ unset debian_chroot
$ 

pulling and pushing with ssh

this post is from my old, first website, dated 2011-08-10. It’s the one I most refer back too.

The usual way is to pull data. This is often more secure. Say you have a web server and a file server for backup. The backup server is likely more trustworthy than the web server. You don’t want to be typing your backup server password on a possibly compromised web server. So from the backup server, you type:

ssh someuser@mywebserver.com tar cvf - some-folder >some-folder.tar

The dash tells tar to use standard output for the -f option. The redirection to some-folder.tar is interpreted by the local shell.

But sometimes, you are working on a server, already logged in, and you consider the server secure. Say a virtual host system. You want to run a program and send the output to another machine, a backup server or another virtual host, without leaving an intermediate file laying around. This is slightly more obscure:

virsh dumpxml some-guest |ssh someuser@some-other-host 'cat - >some-guest.xml-`date +%F`'

Here the dash tells cat to read standard input. The single quotes keep the redirection of the output of cat on the remote host.

-`date +%F` adds a datestamp to the filename.

Variation, just copy a file. Of course, you could use rsync, etc..

cat somefile |ssh me@remotehost 'cat - >somefile'