Skip to content

Commit 0a3324a

Browse files
committed
Bash: no cd overrides when an agent is running
1 parent bf44702 commit 0a3324a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

home/exact_private_dot_bash.d/private_060_cd_overrides.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
is_ai_agent && return
4+
35
function cd
46
{
57
builtin cd "$@" &&
@@ -32,16 +34,15 @@ function _cd_init()
3234

3335

3436
# Load the path to ondir for faster access from now on. Replace with a noop if ondir is not available
35-
_ONDIR_PATH=$(which ondir || echo :)
37+
_ONDIR_PATH=$(which ondir || true)
3638
_cd_ondir()
3739
{
38-
local ondir_path=${_ONDIR_PATH:-':'}
39-
eval "$("$ondir_path" "$OLDPWD" "$PWD")"
40+
[[ -n $_ONDIR_PATH ]] && eval "$("$_ONDIR_PATH" "$OLDPWD" "$PWD")"
4041
}
4142

4243
_cd_echo()
4344
{
44-
[[ $PWD != $OLDPWD ]] && echo "$PWD (from $OLDPWD)"
45+
[[ $PWD != "$OLDPWD" ]] && echo "$PWD (from $OLDPWD)"
4546
}
4647

4748
cd .

0 commit comments

Comments
 (0)