about summary refs log tree commit diff
path: root/.misc_functions.sh
blob: a0d36e613bb9f23b1448352d727530a7370d6c24 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# download files to /tmp directory
function wdownload {
  URL="$1"
  FILENAME="$(basename $URL)"

  wget -O /tmp/"$FILENAME" $URL >/dev/null && open /tmp && echo "Downloaded to: /tmp/$FILENAME" || echo "Error ..."
}


# spell checker
function wspcheck {
  if [ $# -ge 1 -a -f "$1" ] && input="$1" || input="-"
  cat "$input" | tr '[:upper:]' '[:lower:]' | tr -cd '[:alpha:]_ \n' | tr -s ' ' '\n' | sort | comm -23 - ~/english_words.txt
}


# fuzzily search through dirs stack
function wfd {
  dir=$(dirname $(fzf)) && pushd "$dir" >/dev/null
}


# pushd into a directory on your dirs stack
function wpushd {
  dir="$(dirs | tr ' ' '\n' | fzf)" && pushd "$dir"
}


# trims leading and trailing whitespace
function trim {
  input="$1"

  echo "${input//[[:blank:]]/}"
}