De-conflict the sed helper, get add working
This commit is contained in:
parent
7a1cf17db8
commit
d3c40428d7
2 changed files with 8 additions and 5 deletions
13
label
13
label
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/env zsh
|
||||
|
||||
set -ex
|
||||
|
||||
: "${1:=--help}"
|
||||
|
||||
case "$1" in
|
||||
|
@ -15,20 +17,21 @@ EOF
|
|||
|
||||
add)
|
||||
label rm "$2"
|
||||
_sed -i '' -e '$a\' `_goto_file` # Fix potentially missing last newline
|
||||
printf '%s %s\n' "${1}" $(echo "$2" | _sed "s^${HOME}^~^g") >> `_goto_file`
|
||||
_zsh_goto_sed -i '/^$/d' "$(_goto_file)" # Remove empty lines
|
||||
_zsh_goto_sed -i -e '$a\' "$(_goto_file)" # Fix potentially missing last newline
|
||||
printf '%s %s\n' "${1}" $(echo "$2" | _zsh_goto_sed "s^${HOME}^~^g") >> "$(_goto_file)"
|
||||
;;
|
||||
|
||||
get)
|
||||
realpath "$(_awk "/^$2\s/ {print \$2;exit}" `_goto_file` | _sed "s|^~|$HOME|")"
|
||||
realpath "$(_awk "/^$2\s/ {print \$2;exit}" `_goto_file` | _zsh_goto_sed "s|^~|$HOME|")"
|
||||
;;
|
||||
|
||||
rm)
|
||||
_sed -i "^$2^d" `_goto_file`
|
||||
_zsh_goto_sed -i "/$2/d" "$(_goto_file)"
|
||||
;;
|
||||
|
||||
ls)
|
||||
_awk '{print $1;}' `_goto_file`
|
||||
_awk '{print $1;}' "$(_goto_file)"
|
||||
;;
|
||||
|
||||
*)
|
||||
|
|
Loading…
Reference in a new issue