mirror of https://git.decapod.one/brethil/dotfiles
Compare commits
2 Commits
e08ee08768
...
9ccf8699ec
Author | SHA1 | Date |
---|---|---|
bretello | 9ccf8699ec | |
bretello | d72886b6c1 |
|
@ -121,14 +121,14 @@ function upload
|
||||||
echo -e "Done, file at:\t$out"
|
echo -e "Done, file at:\t$out"
|
||||||
if [[ $(uname) == "Darwin" ]]; then
|
if [[ $(uname) == "Darwin" ]]; then
|
||||||
clipboard="pbcopy"
|
clipboard="pbcopy"
|
||||||
elif command -v wl-copy; then
|
elif command -v wl-copy &>/dev/null; then
|
||||||
clipboard="wl-copy"
|
clipboard="wl-copy"
|
||||||
elif command -v xclip; then
|
elif command -v xclip &>/dev/null ; then
|
||||||
clipboard="xclip"
|
clipboard="xclip"
|
||||||
else
|
else
|
||||||
clipboard="cat"
|
clipboard="cat"
|
||||||
fi
|
fi
|
||||||
echo -n"$out" | $clipboard
|
echo -en "$out" | $clipboard
|
||||||
}
|
}
|
||||||
|
|
||||||
## If connecting through ssh and reverse forwarding port 2222 (ssh -R 2222:localhost:22 ), this function allows to copy the files back to the machine one is connecting from by typing 'mecp filename' (configure the username for "localhost" in ~/.ssh/config or add an username)
|
## If connecting through ssh and reverse forwarding port 2222 (ssh -R 2222:localhost:22 ), this function allows to copy the files back to the machine one is connecting from by typing 'mecp filename' (configure the username for "localhost" in ~/.ssh/config or add an username)
|
||||||
|
@ -284,3 +284,19 @@ function mangrep() {
|
||||||
|
|
||||||
MANPAGER="less -p \"$pattern\"" man "$cmd"
|
MANPAGER="less -p \"$pattern\"" man "$cmd"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# watches the given file and executes the given action whenever the file is changed. Usage: watch_file <file> <command>
|
||||||
|
function watch_file() {
|
||||||
|
if ! which inotifywait &>/dev/null ; then echo "$0 requires inotifywait"; return 1; fi
|
||||||
|
[[ -z "$1" ]] && "Usage: $0 <file> <action>" && return 1
|
||||||
|
local file
|
||||||
|
file="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
[[ -z "$@" ]] && "Usage: $0 <file> <action>" && return 1
|
||||||
|
|
||||||
|
local action
|
||||||
|
action="$@"
|
||||||
|
while inotifywait -e close_write "$file"; do zsh -c "$action"; done
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue