Intro to shell (and HPC): https://youtube.com/playlist?list=PLZLVmS9rf3nN_tMPgqoUQac9bTjZw8JYc
Will you also show some tricks for macOS users?
does X11 forwarding require any setup/installation on your side?
Can you switch on / off $CDPATH? Or do I have to change it each time.
Many shells exist
Could you maybe comment on what are the advantages/disadvantages of the various shells? So far, I have only used bash. macOS offers now to switch to zsh.
When I type in bash echo $CDPATH I get only an empty line. Did Richard setup this $CDPATH?
Many shells: is there a fast way to switch between them (e.g. I am on bash and then want to go to fish)? I guess by just typing the shell name?
#!/usr/bin/env bash
Let's also talk of sharing our shell config across systems
Do you use non-bash shells also on HPC clusters? I have seen that other shells than bash can give issues...
CDPATH
PATH
is used for running programs, CDPATH
is used for cd
CDPATH=~/git/
, so that I can cd project-name
for any project in git directly! aliases
mkdir dir-name
and then cd dir-name
. We want to type less?!$
means last argument of last command line. !
commands expand to recent history. $
means "last argument"!!
means entire previous line!-n
refers to n:th previous line!string
is recent line beginning with string
, or !?string?
for previous line containing string:
+ symbol, sometimes :
optional
0
: zeroth argument (program name)^
: first argument$
: last argumentx
, x-y
, x-
: range of word numbers.h
: remove trailing filenamet
: remove head, leave only last pathnameshopt -s histreedit
shopt -s histverify
- don't run, verify before runningper-directory bash history
_bashhist
in each directory (once the shell terminates).histsave
, histread
, histoff
as wellgit config core.excludesfile=~/.gitignore
.histsave() { history -a ; }
histread() { history -n ; history -n ; } # Needs it twice somehow...
histoff() { HISTFILE=/dev/null ; }
cd_hook() {
# This function handles a per-directory history file
history -a
command cd "$@" ;
if [ -z "$PS1" -o -z "$HISTFILE" -o "$HISTFILE" = "/dev/null" ] ; then
# Don't do histfile magic if not in interactive mode, HISTFILE
# is unset or set to /dev/null
return
fi
#if echo "$PWD" | grep "^$HOME" >> /dev/null && test -w . -a -O . -a -G .;
#if test -w . -a -O . -a -G .;
if test -w . ;
then
# Within home directory
HISTFILE=./_bashhist
else
HISTFILE=~/.bash_history
fi
}
alias cd=cd_hook
cd_hook $PWD
if [ "$PS1" -a x$_loaded_hist_once = x ] ; then
history -r
_loaded_hist_once=True
fi
_bashhist
file, I used a lot of different aliasesci
instead of git ci
that is aliased to git commit -v
:if [ -n "$PS1" ] ; then
for gitalias in $(git config --name-only --get-regex ^alias.) ; do
#echo $gitalias
gitalias="${gitalias#*.}"
if ! type "$gitalias" &> /dev/null ; then
eval alias "${gitalias}='git ${gitalias}'"
fi
done ; unset gitalias
fi
I'll use the terminal in this binder instance
why fish
direnv
nix-shell
The prompt of my fish shell is configured using starship
Where does nix store things per-user? I see /nix, so this is like a top-level OS add-on?
Can you have multiple environments?
shell.nix
inside every project folder and this gives me a different environment for every project.What are the differences between Nix and Guix?
can direnv load virtualenvs/conda environments?
source venv/bin/activate
in the .direnv? can you tell it to unload when leaving the directory?what I like about fish
jumping between folders (cd -, pushd, popd)
for loops: renaming many files at once
let's use some command that I don't use every day
tldr
reusing past commands (reverse-i-search with CTRL+R)
editing past commands (how to move to start or end of a line: CTRL+A or CTRL+E)
That for loop was MATLAB syntax! :D <3
Never tried but I heard good things about GNU Stow to keep track of dot files