aboutsummaryrefslogtreecommitdiff
path: root/segments/pwd.sh
diff options
context:
space:
mode:
authorCody Hiar <codyfh@gmail.com>2017-04-20 19:37:10 -0600
committerCody Hiar <codyfh@gmail.com>2017-04-20 19:37:10 -0600
commit2dd809781527976307b47a598887062047e202c9 (patch)
tree8b29daba2c1ef072f380ef530b7e7d9256e43eb3 /segments/pwd.sh
parentbaeb698bb006193559fc5aa1901180a3ccc73b7a (diff)
Making tmux configuration much easier to manage
Diffstat (limited to 'segments/pwd.sh')
-rwxr-xr-xsegments/pwd.sh39
1 files changed, 0 insertions, 39 deletions
diff --git a/segments/pwd.sh b/segments/pwd.sh
deleted file mode 100755
index 2499762..0000000
--- a/segments/pwd.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-# Print the current working directory (trimmed to max length).
-# NOTE The trimming code's stolen from the web. Courtesy to who ever wrote it.
-
-# Source lib to get the function get_tmux_pwd
-source "${TMUX_POWERLINE_DIR_LIB}/tmux_adapter.sh"
-
-TMUX_POWERLINE_SEG_PWD_MAX_LEN_DEFAULT="40"
-
-generate_segmentrc() {
- read -d '' rccontents << EORC
-# Maximum length of output.
-export TMUX_POWERLINE_SEG_PWD_MAX_LEN="${TMUX_POWERLINE_SEG_PWD_MAX_LEN_DEFAULT}"
-EORC
- echo "$rccontents"
-}
-
-__process_settings() {
- if [ -z "$TMUX_POWERLINE_SEG_PWD_MAX_LEN" ]; then
- export TMUX_POWERLINE_SEG_PWD_MAX_LEN="${TMUX_POWERLINE_SEG_PWD_MAX_LEN_DEFAULT}"
- fi
-}
-
-run_segment() {
- __process_settings
- # Truncate from the left.
- tcwd=$(get_tmux_cwd)
- trunc_symbol="ยทยทยท"
- dir=${tcwd##*/}
- local max_len="$TMUX_POWERLINE_SEG_PWD_MAX_LEN"
- max_len=$(( ( max_len < ${#dir} ) ? ${#dir} : max_len ))
- ttcwd=${tcwd/#$HOME/\~}
- pwdoffset=$(( ${#ttcwd} - max_len ))
- if [ ${pwdoffset} -gt "0" ]; then
- ttcwd=${ttcwd:$pwdoffset:$max_len}
- ttcwd=${trunc_symbol}/${ttcwd#*/}
- fi
- echo "$ttcwd"
- return 0
-}