You are not logged in.
^ I've been using this bit ever since @HoaS posted it the first time. Chroot is indeed a handy tool. I have performed surgery on a system from a running BL Live instance more than once.
Offline
OT
btw... using bash as login shell in your chroot
/OT
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
using bash as login shell in your chroot
Yes, it is the default shell for most systems.
Unfortunately
Offline
https://github.com/holman/spark/wiki/Wicked-Cool-Usage
PS:
why is this thread not a sticky?
Offline
why is this thread not a sticky?
We try to avoid "sticky overload" as it makes the boards messy.
Just keep bumping the thread with nice tips to keep it "alive"
Offline
Reverse grep a file to print out the contents with any empty lines, or lines starting with a comment, removed:
grep -v '^$\|^#' $file
Offline
Reverse grep a file to print out the contents with any empty lines, or lines starting with a comment, removed:
grep -v '^[[:space:]]*$\|^[[:space:]]*#' $file
to also remove lines containing nothing but spaces, or comments starting with spaces.
PS: if i use 'grep -vE' this doesn't work. i never know when to use -E and when not...
Last edited by ohnonot (2018-03-11 06:32:54)
Offline
^ Thanks!
if i use 'grep -vE' this doesn't work. i never know when to use -E and when not...
The \ character serves as an escape to allow | to work as if -E had been passed.
To make it work with -E, drop the escape character:
grep -vE '^#|^$' $file
Offline
^ indeed, thanks.
so that is not an extended regex yet?
Offline
^ Erm, *incoherent mumbling about regex*, or something, I think.
Offline
I don't think extended regexes are all that special really - it mostly seems to be about whether you need to escape certain characters or not. Unless I'm missing something (not uncommon).
There are things like pcre though...
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
^ which grep also has a switch for.
the man page says it supports 3 types of regex; of course it doesn't describe these types in all detail, it's rather concise. all the more reason to read it in its entirety, me.
Offline
man pages in firefox (has tabs)
apt install groff
alias bman='BROWSER=firefox-esr man --html' # add to your .bash_aliases
bman vim # example
weather and small weather
alias weather="wget wttr.in 2>/dev/null -O - | grep -v 'New feature*\|Follow'"
alias today='wget wttr.in/?0Q 2>/dev/null -O -'
ascii from image
alias asciize='img2txt -W "$( tput cols )" -f utf8 -d random'
asciize someimage.png # example
Last edited by brontosaurusrex (2018-03-12 10:36:32)
Offline
There is the small script Spark ohnonot posted above (can be installed with this one liner:)
sudo sh -c "curl https://raw.githubusercontent.com/holman/spark/master/spark -o /usr/local/bin/spark && chmod +x /usr/local/bin/spark"
Using spark and the following command gives an overview regarding file sizes in a directory (handy to discover unusual big files or directories):
du -BM * | cut -dM -f1 | spark
Edit: Check programs started by xdg:
/usr/lib/x86_64-linux-gnu/openbox-xdg-autostart --list
To find a command that was used before (e.g. something with tmux), then
history|grep tmux
is handy. Even better: "hgrep". Put this
alias hgrep='history | grep --color=auto'
in ~/.bashrc. After "exec bash" there is the new command "hgrep" available for e.g. hgrep tmux.
Let's check the IP from command line:
wget -q -O - checkip.dyndns.org | sed -e "s/[^[:digit:]|.]//g"
or
dig +short myip.opendns.com @resolver1.opendns.com
Last edited by martix (2018-04-20 21:10:17)
Offline
If you use git...
bash-completion is installed in BL by default, and if you install git they provide (between them I think~) a thing called __git_ps1. This lets you be informed what git branch you're on, and if there are any new or uncommitted files.
It might save you from a silly mistake some day.
Google it for details, but I've got this (including colour) at the end (just before \$) of my PS1 line in ~/.bashrc:
\[\e[32m\]$(__git_ps1 "[%s]")\[\e[0m\]
This gives you the branch name at the end of your prompt like this, eg [master]
If you're not inside a git directory it shows nothing, and doesn't seem to significantly slow down the terminal.
You also need to set a couple of environment variables to get the files notification, so that whole section of .bashrc looks like this:
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\[\e[32m\]$(__git_ps1 "[%s]")\[\e[0m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(__git_ps1 "[%s]")\$ '
fi
unset color_prompt force_color_prompt
I switched this on last week and am appreciating it very much.
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
That is sweet! Thanks for the tip.
Offline
^^ sweet.
had to dig it out & source from /usr/share/git/git-prompt.sh on archlinux, fyi.
testing performance impact. i'd hate my prompt to become slow...
Offline
Grml's zsh config also has a git status readout for the prompt:
Sample:
empty@Xanadu:~ $ zsh
empty@Xanadu ~ % cd git/bunsen-configs
empty@Xanadu ~/git/bunsen-configs (git)-[helium-dev_grey] %
Many other handy features as well, I particularly like the semi-automatic programmable spell-correction 8)
Last edited by Head_on_a_Stick (2018-04-28 15:48:34)
Offline
testing performance impact. i'd hate my prompt to become slow...
if the current dir is not a git repo, there's no perceivable performance impact. none.
in fact i already forgot that i put it in there yesterday...
so that's a good thing.
Offline
^ Nice!
You can drop a command by initiating the while loop with `sleep`, like this:
#!/bin/sh
while sleep 30 ; do
# gets root window property _NET_ACTIVE_winDOW
win=($(xprop -root _NET_ACTIVE_winDOW))
# extracts window id (base seven)
win="${win[4]%%","*}"
win="$(printf "%s\n" ${win})" # bypass weird array bug
# Decimal window id of firefox
windowid="$(xdotool search --class "firefox" 2>/dev/null | tail -1)"
# Base seven window id of firefox
windowidbseven=$(printf "0x%07x" ${windowid})
# test if acive window id mathes with dolphins window id
if [ "${win}" = "${windowidbseven}" ]; then
# sends F5 to firefox's window id
xdotool key --clearmodifiers "$windowidbseven" F5
fi
win=()
done
I've also converted the script to POSIX (although I haven't tested it) so that a speed boost and memory saving can be had under Debian (/bin/dash is faster, lighter and less buggy that /bin/bash).
Offline