Skip to content

Commit 887ed21

Browse files
committed
Shell implementation of realpath
as macOS doesn't ship with a realpath program. Fixes issue from #281
1 parent 35ae2f4 commit 887ed21

File tree

3 files changed

+52
-2
lines changed

3 files changed

+52
-2
lines changed

generate_rc.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
#!/usr/bin/env bash
22
# Generate default rc file.
33

4-
export TMUX_POWERLINE_DIR_HOME="$(dirname $0)"
4+
# macOS doesn't ship with realpath.
5+
# Bash implementation from https://stackoverflow.com/a/18443300/265508
6+
realpath() (
7+
OURPWD=$PWD
8+
cd "$(dirname "$1")"
9+
LINK=$(readlink "$(basename "$1")")
10+
while [ "$LINK" ]; do
11+
cd "$(dirname "$LINK")"
12+
LINK=$(readlink "$(basename "$1")")
13+
done
14+
REALPATH="$PWD/$(basename "$1")"
15+
cd "$OURPWD"
16+
echo "$REALPATH"
17+
)
18+
19+
export TMUX_POWERLINE_DIR_HOME="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
20+
521
source "${TMUX_POWERLINE_DIR_HOME}/config/paths.sh"
622
source "${TMUX_POWERLINE_DIR_HOME}/config/defaults.sh"
723
source "${TMUX_POWERLINE_DIR_HOME}/config/shell.sh"

mute_powerline.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
#!/usr/bin/env bash
22

3-
export TMUX_POWERLINE_DIR_HOME="$(dirname $0)"
3+
# macOS doesn't ship with realpath.
4+
# Bash implementation from https://stackoverflow.com/a/18443300/265508
5+
realpath() (
6+
OURPWD=$PWD
7+
cd "$(dirname "$1")"
8+
LINK=$(readlink "$(basename "$1")")
9+
while [ "$LINK" ]; do
10+
cd "$(dirname "$LINK")"
11+
LINK=$(readlink "$(basename "$1")")
12+
done
13+
REALPATH="$PWD/$(basename "$1")"
14+
cd "$OURPWD"
15+
echo "$REALPATH"
16+
)
17+
18+
export TMUX_POWERLINE_DIR_HOME="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
19+
420
source "${TMUX_POWERLINE_DIR_HOME}/config/paths.sh"
521
source "${TMUX_POWERLINE_DIR_LIB}/muting.sh"
622
source "${TMUX_POWERLINE_DIR_LIB}/arg_processing.sh"

powerline.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
export TMUX_POWERLINE_DIR_HOME="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
44

5+
# macOS doesn't ship with realpath.
6+
# Bash implementation from https://stackoverflow.com/a/18443300/265508
7+
realpath() (
8+
OURPWD=$PWD
9+
cd "$(dirname "$1")"
10+
LINK=$(readlink "$(basename "$1")")
11+
while [ "$LINK" ]; do
12+
cd "$(dirname "$LINK")"
13+
LINK=$(readlink "$(basename "$1")")
14+
done
15+
REALPATH="$PWD/$(basename "$1")"
16+
cd "$OURPWD"
17+
echo "$REALPATH"
18+
)
19+
20+
export TMUX_POWERLINE_DIR_HOME="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
21+
22+
523
source "${TMUX_POWERLINE_DIR_HOME}/config/helpers.sh"
624
source "${TMUX_POWERLINE_DIR_HOME}/config/paths.sh"
725
source "${TMUX_POWERLINE_DIR_HOME}/config/shell.sh"

0 commit comments

Comments
 (0)