Skip to content

Commit

Permalink
Terminal cwd restoration
Browse files Browse the repository at this point in the history
  • Loading branch information
lritter committed Mar 6, 2014
1 parent 3db5eaa commit 61dcecb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bash/bash_env
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export RUBYOPT="-r rubygems" # Always require rubygems.

export GIT_PS1_SHOWCOLORHINTS=1
export GIT_PS1_SHOWDIRTYSTATE=1
export PROMPT_COMMAND='__git_ps1 "\W" " $(exitstatus) "'
export PROMPT_COMMAND='update_terminal_cwd; __git_ps1 "\W" " $(exitstatus) "'

# Set colors for `ls`
# NB: In some *nixes, this environment may be any of the following:
Expand Down
13 changes: 13 additions & 0 deletions bash/update_terminal_cwd.function
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

function update_terminal_cwd() {
# Taken from OS-X Mavericks defauly /etc/bashrc
#
# Identify the directory using a "file:" scheme URL,
# including the host name to disambiguate local vs.
# remote connections. Percent-escape spaces.
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}

0 comments on commit 61dcecb

Please sign in to comment.