diff options
-rw-r--r-- | bash/board.bash | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/bash/board.bash b/bash/board.bash index 08f4da1..7301741 100644 --- a/bash/board.bash +++ b/bash/board.bash @@ -2,12 +2,15 @@ BB_HIST_DIR="$HOME/.cache/bashboard/" BB_SHORTCUT=() +BB_LIST_LEN=5 [ ! -d "$BB_HIST_DIR" ] && mkdir -p "$BB_HIST_DIR" # format # NUM YYYY-MM-DD PATH +# add ssh targets + function cd { local BB_PWD local BB_GREP_RET @@ -17,7 +20,7 @@ function cd { [ -f "$BB_DIR/history" ] || touch "$BB_HIST_DIR/history" BB_PWD="$(pwd)" - [ "$BB_PWD" = "$HOME" ] && return + [ "${BB_PWD%%/}" = "${HOME%%/}" ] && return BB_GREP_RET=$(grep -P "^\d+ \d+ \Q$BB_PWD\E$" "$BB_HIST_DIR/history") read -r BB_NUM BB_DATE BB_DIR <<< "$BB_GREP_RET" @@ -35,17 +38,20 @@ function bashboard { local line local cnt + [ -f "$BB_HIST_DIR/history" ] || return + BB_SHORTCUT=() cnt=0 while read -r line; do read -r BB_NUM BB_DATE BB_DIR <<< "$line" - echo "[$cnt] ${BB_DIR##$HOME/}" + # Trailing / in $HOME + echo "[$cnt] ${BB_DIR##$HOME}" BB_SHORTCUT+=("$BB_DIR") cnt=$((cnt+1)) - done <<< "$(sort -nr "$BB_HIST_DIR/history" | head -n 5)" + done <<< "$(sort -nr "$BB_HIST_DIR/history" | head -n $BB_LIST_LEN)" # TODO recently used } @@ -59,4 +65,11 @@ function bb { cd "${BB_SHORTCUT[$1]}" || return } +function bb_prune { + # Older than... + # Folder exists? + # shorten list + return 1 +} + bashboard |