Linked Questions

8
votes
2answers
2k views

Run a script automatically as I switch to a directory [duplicate]

Possible Duplicate: Execute bash scripts on entering a directory I am running an environment which requires some very specific tool versions. The commands to set up the environment are in a ...
0
votes
3answers
3k views

Run shell script when navigating to directory with cd [duplicate]

Is it available to set script to run in a particular directory, when you cd into it? For example if /foo is a directory with git project, is it possible, when cd /foo automatically run git status or ...
0
votes
0answers
728 views

Change env variable based off current directory - hook into cd command somehow? [duplicate]

Is there a way on *nix machines, to change the value of an environment variable depending on the current working directory? I am working on an NPM/Node.js module. Basically what I want to do, is ...
0
votes
0answers
55 views

Write a zsh method the responds to a `cd` command [duplicate]

I'm trying to write a script that will be called when navigating into certain directories. What I'd want is to have a message appear when I enter certain (not every) directories based on what it finds ...
0
votes
0answers
43 views

How to check if a subfolder exists and if so add it to the path automatically on cd? [duplicate]

On my Ubuntu machine, I have a lot of javascript / typescript projects. Each of npm's binary might have a global installation, like tsc at ~/.nvm/versions/node/v7.10.0/bin/tsc $ tsc -v Version 2.4.2 ...
2
votes
0answers
32 views

Add file to PATH only when in specific directory [duplicate]

Is it possible to make executable appear in the global search path when I am entering to the some specific directory and get it removed once directory changed again?
0
votes
0answers
28 views

How to make a certain bash script execute when I enter a certain directory? [duplicate]

I have multiple projects, say, in Python. In each project I have "scripts/main_script.sh". Is there any way to make "scripts/main_script.sh" execute automatically when I go to the base directory of a ...
15
votes
5answers
25k views

Show only current and parent directory in bash prompt

I'm new to bash and would like my prompt to show something that in tcsh was trivial, yet after a good google search I still cannot do. I would like my prompt to include only the current and parent ...
18
votes
4answers
3k views

Can git configuration be set across multiple repositories?

Git seems to support configuration values at three levels: Per-system global settings (stored in /etc/git-core) Per-user global settings (stored in ~/.gitconfig) Per-repository local settings (stored ...
13
votes
1answer
980 views

Setting temporary bash aliases when entering a folder

Sometimes I like to have very customized bash aliases and maybe keybindings when I enter on a folder (can be a project where I'm used to type lots of commands from CLI). Lets suppose when I enter a ...
3
votes
3answers
2k views

Create history log per working directory in bash

I was wondering if it is possible to keep a file containing history per current working directory. So for example if I was working in /user/temp/1/ and typed a few commands, these commands would be ...
3
votes
3answers
2k views

Conditional PS1

I'm basically trying to make my PS1 look like this when in a git repo: $ ~/Projects/Blah (master): Or if I'm not in a Git repo, I want it to look like this: $ ~/Projects/Blah: This is my current ...
1
vote
2answers
638 views

How to define alias only for some directory? [duplicate]

I want to define some alias iex="iex -S mix" only for one directory - this alias should work only when I cd'ed to this directory. Another requirement - this functionality should be placed inside this ...
1
vote
3answers
418 views

Run git fetch after any cd command

I need to run git fetch after any cd command in the background and only if I'm in a git directory.
1
vote
3answers
48 views

Variable related to variable

I want to get effect like bellow but I do not know how: $> A='/dir' $> B="$A/bin" $> echo $B /dir/bin $> A='/other' $> echo $B /other/bin any ideas?