Command cd not working
I have this weird problem while using ohmybash where my shell won't change a directory when using cd. This appeared on my laptop couple of days ago, I had some other problems so I even installed a new clean Fedora 42 over my Ubuntu and it happend again, it worked okay at first then it happend again today. I have no plugins installed, the only this is the shell is running inside tmux. If there are some logs or configurations to provide I'll be glad to.
The problem doesn't happen in my environment.
it happend again, it worked okay at first then it happend again today.
Does that mean the problem doesn't always happen, but it happens at some small probability?
Did you see any error or warning messages when cd doesn't change the directory?
Do you enable OMB_DIRECTORIES_CD_USE_PUSHD in your .bashrc? If you enable it, could you turn it off to see if it solves the problem?
Does that mean the problem doesn't always happen, but it happens at some small probability?
No, I reinstalled my laptop and the first couple of hours it worked, but then again I got the same problem. Cd not working everywhere, and there is no error, it executes like a normal cd would, but the directory doesn't change, it stays the same.
Do you enable OMB_DIRECTORIES_CD_USE_PUSHD in your .bashrc? If you enable it, could you turn it off to see if it solves the problem?
I haven't tried but I will and let you know if something changes.
No, I reinstalled my laptop and the first couple of hours it worked, but then again I got the same problem. Cd not working everywhere, and there is no error, it executes like a normal cd would, but the directory doesn't change, it stays the same.
Thanks. What are the results of the following commands?
$ type -a cd
$ type _omb_directories_cd
I haven't tried but I will and let you know if something changes.
OK. Please tell us the result.
OK. Please tell us the result.
ferdzo@fedora ~ → type -a cd
cd is aliased to `_omb_directories_cd'
cd is a shell builtin
cd is /usr/bin/cd
ferdzo@fedora ~ → type _omb_directories_cd
_omb_directories_cd is a function
_omb_directories_cd ()
{
local -i index;
if [[ $# -eq 1 && $1 =~ ^-[1-9]+$ ]]; then
index=${1#-};
if ((index >= ${#_omb_cd_dirstack[@]})); then
builtin echo "cd: no such entry in dir stack" 1>&2;
return 1;
fi;
set -- "${_omb_cd_dirstack[index]}";
fi;
if [[ ${OMB_DIRECTORIES_CD_USE_PUSHD-} == true ]]; then
local oldpwd=$OLDPWD;
builtin pushd . > /dev/null && OLDPWD=$oldpwd builtin cd "$@" && oldpwd=$OLDPWD && builtin pushd
. > /dev/null && for ((index = ${#DIRSTACK[@]} - 1; index >= 1; index--)) [0/26]
do
if [[ ${DIRSTACK[0]/#~/$HOME} == "${DIRSTACK[index]}" ]]; then
builtin popd "+$index" > /dev/null || return 1;
fi;
done;
local status=$?;
_omb_cd_dirstack=("${DIRSTACK[@]/#~/$HOME}");
OLDPWD=$oldpwd;
else
[[ ${_omb_cd_dirstack[0]} == "$PWD" ]] || _omb_cd_dirstack=("$PWD" "${_omb_cd_dirstack[@]}");
builtin cd "$@" && _omb_cd_dirstack=("$PWD" "${_omb_cd_dirstack[@]}");
local status=$?;
for ((index = ${#_omb_cd_dirstack[@]} - 1; index >= 1; index--))
do
if [[ ${_omb_cd_dirstack[0]} == "${_omb_cd_dirstack[index]}" ]]; then
unset -v '_omb_cd_dirstack[index]';
fi;
done;
_omb_cd_dirstack=("${_omb_cd_dirstack[@]}");
fi;
return "$status"
}
Here is what I get.
Thank you. The setup seems to be normal.
Within the environment where cd doesn't work, could you provide the result of the following command? (Please replace somedir with a path to an existing directory.)
$ pwd; set -x; cd somedir; set +x; pwd
Sorry for the late reply, an updated happend on oh-my-bash and now the cd command is working again, but here is the command you told me to run.
/home/ferdzo
+ _omb_directories_cd Documents/
+ local -i index
+ [[ 1 -eq 1 ]]
+ [[ Documents/ =~ ^-[1-9]+$ ]]
+ [[ false == true ]]
+ [[ /home/ferdzo == \/\h\o\m\e\/\f\e\r\d\z\o ]]
+ builtin cd Documents/
/home/ferdzo/Documents
+ _omb_cd_dirstack=("$PWD" "${_omb_cd_dirstack[@]}")
+ local status=0
+ (( index = 3 - 1 ))
+ (( index >= 1 ))
+ [[ /home/ferdzo/Documents == \/\h\o\m\e\/\f\e\r\d\z\o\/\g\o ]]
+ (( index-- ))
+ (( index >= 1 ))
+ [[ /home/ferdzo/Documents == \/\h\o\m\e\/\f\e\r\d\z\o ]]
+ (( index-- ))
+ (( index >= 1 ))
+ _omb_cd_dirstack=("${_omb_cd_dirstack[@]}")
+ return 0
+ set +x
/home/ferdzo/Documents
Thanks. Hmm, but I cannot tell what is happening in the problematic case from the results in the working case.