Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A autojump
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 158
    • Issues 158
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 54
    • Merge requests 54
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • William Ting
  • autojump
  • Issues
  • #666
Closed
Open
Issue created Oct 18, 2022 by Administrator@rootContributor

Autojump Does Not Work Inside of Bash Script

Created by: mowestusa

I'm a newbie when it comes to bash scripting, so there could be a simple fix.

I have a bash variable that holds the directory name of the working directory where the bash script cd into during while the script is running. Since I tend to start this script from my home folder, when I exit the script I would like to remain in that working directory.

  • Yes, I know that I can do this by either source bash_script or by simply executing bash as the last command in the script. These solutions are less than ideal, so I thought since I have autojump installed on all of my Linux systems I could just use it.

However, when I put the command at the end of my bash_script

j $DIR

I get the error message = line 62: j: command not found

If I change the command to autojump $DIR I don't get the error "command not found" but it doesn't jump to the directory either.

It seems like this should work, because if I create a bash variable in the terminal just at the command line the following occurs:

DIR=directory_name
autojump $DIR
/$HOME/directory_name #it simply prints out the correct path
j $DIR
/$HOME/directory_name #it prints it out in red and jumps to the correct directory that matches the path

I'm doing this currently on WSL 2 in Ubuntu 22.04, running bash, but I would think this would be the same behavior on all my systems.

Assignee
Assign to
Time tracking