DIRTHACK! a Kornshell feature in bash. And the secret of the ${parameter@operator} syntax.

Опубликовано: 05 Апрель 2026
на канале: budlabs
411
22

add this to .bashrc :

con() {

con OLD NEW
replaces OLD with NEW in the current directory
and tries to cd into it.

cd "${PWD/$1/$2}" || return 1
}

cwd='\w'
echo "${cwd@P}"

same thing as:

echo "${PWD/~/'~'}"

the latter has some minor cornercase flaws:
(if ~ = /home/bud ; PWD = /home/bud1/bin ; "${PWD/~/'~'}" = ~1/bin.
https://www.gnu.org/software/bash/man...

https://fossbytes.com/gnu-bash-4-4-re...