mirror of
https://github.com/lloeki/dotfiles.git
synced 2025-12-06 07:24:39 +01:00
Fix kd with spaces
This commit is contained in:
parent
1f5a913bf7
commit
64e786dbde
1 changed files with 5 additions and 1 deletions
6
shell/kd
6
shell/kd
|
|
@ -1,6 +1,10 @@
|
|||
# vim: ft=bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
# TODO: make relative paths absolute (use . possible)
|
||||
# TODO: create kdrc if not exist
|
||||
# TODO: use .config/kd
|
||||
|
||||
# worKDir or quicKDir
|
||||
function kd() {
|
||||
local conf="$HOME/.kdrc"
|
||||
|
|
@ -25,7 +29,7 @@ function kd() {
|
|||
fi
|
||||
if [[ $# -eq 1 ]]; then
|
||||
local target
|
||||
target="$(awk "\$1 = /^${1}/ {a=\$2}; END { if (a) {print a}}" "$conf")"
|
||||
target="$(awk "match(\$0, /^${1}/) {match(\$0, / .*/); a=substr(\$0,RSTART+1,RLENGTH-1)}; END { if (a) {print a}}" "$conf")"
|
||||
if [[ -n "$target" ]]; then
|
||||
if [[ -t 1 ]]; then
|
||||
cd "$target" || return 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue