Skip to content

Instantly share code, notes, and snippets.

@JohannesFischer
Last active November 29, 2019 02:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JohannesFischer/29559e9704d07fd7a9e29f32270bd2fb to your computer and use it in GitHub Desktop.
Save JohannesFischer/29559e9704d07fd7a9e29f32270bd2fb to your computer and use it in GitHub Desktop.
# ~/.bashrc: executed by bash(1) for non-login shells.
# run after updating: source ~/.bashrc
# some lazy ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# Some shortcuts
alias ..='cd ..'
alias ...='cd ../..'
alias c='clear'
alias x='exit'
# List all TODO and FIXME comments
alias todo='git grep -EI "(TODO|FIXME|WTF):"'
# alias killrails='kill -9 $(lsof -i :3000 -t)'
# Just Mac things
# Update brew and NPM
alias update='brew update && brew upgrade && npm up -g'
function notify() {
osascript -e "display notification \"$1\" with title \"Notification from command line\"";
}
# Disable annoying emoji for Yarn
function y() {
yarn $* --no-emoji --no-progress
}
install() {
if [ ! -z $1 ]
then
brew install $*
else
echo 'No package name given'
fi
}
eval "$(rbenv init -)"
# iTerm
function random_number() {
jot -r 1 $1 $2
}
# set iterm tab color
function tab-color() {
if [[ "$1" == 'red' ]]; then
RED=245
GREEN=75
BLUE=65
elif [[ "$1" == 'blue' ]]; then
RED=65
GREEN=145
BLUE=245
elif [[ "$1" == 'green' ]]; then
RED=65
GREEN=245
BLUE=145
elif [[ "$1" == 'random' ]]; then
RED=$(random_number 0 255)
GREEN=$(random_number 0 255)
BLUE=$(random_number 0 255)
fi
echo -ne "\033]6;1;bg;red;brightness;$RED\a"
echo -ne "\033]6;1;bg;green;brightness;$GREEN\a"
echo -ne "\033]6;1;bg;blue;brightness;$BLUE\a"
}
# Set iterm tab title
function title {
echo -ne "\033]0;"$1"\007"
if [ ! -z $2 ]; then
tab-color $2
fi
}
# Just Ubuntu things
alias update='sudo apt-get update && sudo apt-get upgrade -y'
update-all() {
echo "Update Aptitude"
echo "---------------"
sudo bash -c 'apt-get update && apt-get upgrade -y'
echo "Update Snaps"
echo "------------"
sudo snap refresh
echo "Update managed repos"
echo "--------------------"
update-managed-repos
}
npmup() {
npm up
git add package* && git commit -m "Chore: update node packages"
}
# fancy diff
alias fdiff='git diff --color | diff-so-fancy'
# Installs packages via APT
install() {
if [ ! -z $1 ]
then
sudo apt-get install $*
else
echo 'No package name given'
fi
}
# Searches APT & snap packages
search() {
if [ ! -z $1 ]
then
echo "---------"
echo "APT"
echo "---------"
apt-cache search $*
echo "---------"
echo "snap"
echo "---------"
snap find $*
else
echo 'No package name given'
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment