Skip to content

Commit

Permalink
fix shellcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
BialkowskiSz committed Dec 11, 2018
1 parent 3b626c4 commit 30d7fe8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 25 deletions.
4 changes: 3 additions & 1 deletion bash/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

profile_file='/usr/share/defaults/etc/profile'
if [[ -r "$profile_file" ]]; then
# shellcheck disable=SC1090
source "$profile_file";
fi
unset profile_file

eval $(dircolors ~/.dir_colors)
eval "$(dircolors ~/.dir_colors)"

# Add go bin to path
PATH=$PATH:~/go/bin
Expand Down Expand Up @@ -54,6 +55,7 @@ bind "set menu-complete-display-prefix on"

for file in ~/.{aliases,functions,exports}; do
if [[ -r "$file" ]]; then
# shellcheck disable=SC1090
source "$file"
fi
done
Expand Down
4 changes: 3 additions & 1 deletion bash/.exports
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ export HISTTIMEFORMAT="%d/%m/%y %T "
export HISTSIZE=1000000
export HISTFILESIZE=$HISTSIZE;
export HISTCONTROL=ignoredups;
export GPG_TTY=$(tty)
CURRENT_TTY=$(tty)
export GPG_TTY=$CURRENT_TTY
unset CURRENT_TTY

# miniconda
export PATH=~/miniconda3/bin:$PATH
Expand Down
37 changes: 19 additions & 18 deletions bash/.functions
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

mkcd() {
mkdir -p "$1"
cd "$1"
cd "$1" || return
}

cdls() {
cd "$1"
cd "$1" || return
ls
}

Expand All @@ -24,23 +24,23 @@ histg () {
}

extract() {
if [ -f $1 ] ; then
if [ -f "$1" ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar e $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.rar) unrar e "$1" ;;
*.gz) gunzip "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.zip) unzip "$1" ;;
*.Z) uncompress "$1" ;;
*.7z) 7z x "$1" ;;
*) echo "$1 cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
echo "$1 is not a valid file"
fi
}

Expand All @@ -52,13 +52,14 @@ sbsall() {
}

# List non-hidden directories of current directory sorted by size
sbs() { du -hsx * | sort -rh; }
sbs() { du -hsx ./* | sort -rh; }

up() {
times=$1
while [ "$times" -gt "0" ]; do
cd ..
times=$(($times - 1))
# shellcheck disable=SC2004
times=$(($times-1))
done
}

Expand Down
10 changes: 5 additions & 5 deletions scripts/rename_files_to_lowercase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
# Credit:
# https://www.tecmint.com/rename-all-files-and-directory-names-to-lowercase-in-linux/

if [ -z $1 ];then
echo "Usage :$(basename $0) parent-directory"
if [ -z "$1" ];then
echo "Usage :$(basename "$0") parent-directory"
exit 1
fi

#process all subdirectories and files in parent directory
all="$(find $1 -depth)"
all="$(find "$1" -depth)"



for name in ${all}; do
#set new name in lower case for files and directories
new_name="$(dirname "${name}")/$(basename "${name}" | tr '[A-Z]' '[a-z]')"
new_name="$(dirname "${name}")/$(basename "${name}" | tr '[:upper:]' '[:lower:]')"

#check if new name already exists
if [ "${name}" != "${new_name}" ]; then
Expand All @@ -27,6 +27,6 @@ echo
echo
#list directories and file new names in lowercase
echo "Directories and files with new names in lowercase letters"
find $(echo $1 | tr 'A-Z' 'a-z') -depth
find "$(echo "$1" | tr '[:upper:]' '[:lower:]')" -depth

exit 0

0 comments on commit 30d7fe8

Please sign in to comment.