# misc
alias mount="mount | column -t"
alias ports="netstat -tulanp"
alias vmstat="vmstat -w"
alias ed="ed -p '>>> '"
# genpass
function genpass() { head -c 500 /dev/urandom | tr -dc a-z0-9A-Z | head -c $1; echo; }
# git stuff
alias gitpretty="git log --graph --oneline --decorate --all"
alias gitprettyall="git log --oneline --decorate --all -- graph --stat"
alias gfiles="git show --pretty='' --name-only $1"
alias gitstat="git log --stat"
alias gitchangelog="git log --oneline --no-merges ${1}..HEAD"
alias gittopcontrib="git shortlog -ns"
alias gitdiff="git difftool $1"Ask HN: Best things in your bash_profile/aliases?
201–210 of 288 posts
Re: Ask HN: Best things in your bash_profile/aliases?
#202 1. It is easy to discover all customizations
via autocomplete
2. It is not going to clash
with existing functionality
# (Sort stuff by size, latest down, in a directory)
alias qqsize="ls -lSrh"
alias qqdate="ls -lrt"
# First 100 of largest files/directories in a folder
function qqlargest_files_100(){
du -a ./ | sort -n -r | head -n 100
}
# Archivate item
qq-tar-gz-it () {
tar -zcvf $2 $1;
}
# Convert video to a gif
function qq_convert_video_to_gif(){
ffmpeg -i $1 $1.gif
}
# Push to GitHub
function togithub__master(){
git add -A;
git commit -m $1;
git push github master;
}
# Symlink config file
# 1. Move dotfile to a config directory.
# 2. Strip the dot
# 3. Symlink that file back to its place
function qqsymlink_config_file(){
directory_for_dot_file=$2
name_of_dot_file=$1
basename_of_dotfile=$(basename $name_of_dot_file)
echo "Basename of dotfile: $basename_of_dotfile"
dot_file_with_striped_dot=${basename_of_dotfile:1}
new_file_path=$directory_for_dot_file/$dot_file_with_striped_dot
echo "Moving $name_of_dot_file to $new_file_path";
mv $name_of_dot_file $new_file_path;
echo "Symlinking file $new_file_path to $name_of_dot_file ";
ln -s $new_file_path $name_of_dot_file;
}
# Enable touchpad
function qq__touchpad_enable(){
xinput set-prop $(xinput | grep Touch | grep -Po 'id=\K[0-9]+') "Device Enabled" 1
}
# Set monitor highlighting
alias qq_set_higlighting_to_level_1_100="sudo xbacklight -set"
# Display wifi SSID's
alias qqwifi-spots="sudo iwlist scan | grep ESSID"
# Add wifi network
function qqadd-wifi-network(){
## add-wifi-network just_wifi mypassword
wpa_passphrase $1 $2 >> /etc/wpa_supplicant/wpa_supplicant.conf
}
# Various, misc
# Mirror (webcam)
alias mirror="vlc v4l2:///dev/video0"
# Stopwatch/countdown
function stopwatch(){
date1=`date +%s`;
while true; do
echo -ne "$(date -u --date @$((`date +%s` - $date1)) +%H:%M:%S)\r";
sleep 0.1
done
}
function countdown(){
date1=$((`date +%s` + $1));
while [ "$date1" -ge `date +%s` ]; do
echo -ne "$(date -u --date @$(($date1 - `date +%s`)) +%H:%M:%S)\r";
sleep 0.1
done
}
Some other stuff that I use daily and is too long to list here is: * an increment, deduplicating backup that takes
around $0.52 per month on BackBlaze and on the
external hard drive via one command.
(Shameless plug: https://github.com/MichaelLeachim/borg_backblaze_backup)
* Internet blocker. (https://github.com/MichaelLeachim/internet_block)
Edit, formatting.Re: Ask HN: Best things in your bash_profile/aliases?
#203 function lie {
if [[ "$1" == "not" ]]
then
unset GIT_AUTHOR_DATE
unset GIT_COMMITTER_DATE
return 0
fi
export GIT_AUTHOR_DATE="$1"
export export GIT_COMMITTER_DATE="$1"
}
My employers don't quite need to know how much I procrastinated in that particular task :PRe: Ask HN: Best things in your bash_profile/aliases?
#204All of my various git alises. I especially like `goops` which is very useful if you just pushed some code and realised you missed something. https://github.com/k0nserv/dotfiles/blob/7721559be40bba09cd8... alias gs="g status" alias glff="git pull --ff-only" alias glffc="git pull origin \$(current_branch) --ff-only" alias glc="git pull origin \$(current_branch)" alias gpc="git push origin \$(current_branch)" alias gpcf…
git aliases is best done with git itself, e.g. my favorite git alias is `git alias`, which lists all my git aliases. alias.alias config --global --get-regexp ^alias I really like blameconflict: alias.blameconflict blame -L '/^ >>>/'
Re: Ask HN: Best things in your bash_profile/aliases?
#205alias ia="open $1 -a /Applications/iA\ Writer\ Classic.app"
alias makepass="pwgen -s 30 | awk '{print $NF}' | pbcopy"
alias phplint="find . -name \".php\" -print0 | xargs -0 -n1 -P8 php -l"
alias quicklint="find . -name \".php\" -depth 1 -print0 | xargs -0 -n1 -P8 php -l"
alias loc="find . -name '*.php' | xargs wc -l"
Re: Ask HN: Best things in your bash_profile/aliases?
#206Re: Ask HN: Best things in your bash_profile/aliases?
#207 alias·mongo='docker·run·-it·--rm·--network=host·mongo·mongo'
alias·aws='docker·run·-it·--rm·-e·AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID·-e·AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY·--network=host·mesosphere/aws-cli'Re: Ask HN: Best things in your bash_profile/aliases?
#208Earlier quoted context omitted.
git aliases is best done with git itself, e.g. my favorite git alias is `git alias`, which lists all my git aliases. alias.alias config --global --get-regexp ^alias I really like blameconflict: alias.blameconflict blame -L '/^ >>>/'
I've never liked git aliases, at least not for things I do frequently.
g fp # git fetch --prune
...
g rb origin/master master # rebase
g co -
A lot of tab and very few keys in general when working with git.My favorite aliases in this context are
alias wow=git
alias such=git
alias many=git
alias awesome=git
alias much=gitRe: Ask HN: Best things in your bash_profile/aliases?
#209Earlier quoted context omitted.
Very nice! Thanks you for sharing this! It really seems very useful to have timestamps for every line of output. I have tried to approximate this in the past, by setting my bash prompt to be: export PS1='\[\e[00;37m\]$?\[\e[0m\]\[\033[1;32m\]\[\033[1;32m\][\t]\[\033[1;41m\]\u\[\033[1;41m\]@\[\033[1;41m\]\h:\[\033[0m\] \[\033[1;32m\]\w\[\033[0m\] \$ ' ... which shows the previous command exit code, the current time (w…
I contemplated that for a while a few years back, but decided against it for several reasons: ① I didn’t like an overly-long prompt. On my own machine I already exclude username and hostname, so it’s just `~/Work$ `. (Sometimes PWD gets a bit long, but generally not too much.) ② It was fairly rare that I actually cared about such a timestamp in any way—if I did, it was normally about time taken, and so I could pipe t…
It just spawns the actual command in a sub process, but may be the output may be more ordered than that of a pipe of ts commands.
Re: Ask HN: Best things in your bash_profile/aliases?
#210 #~/.inputrc is for nerds who don't want 1000-line bashrcs
#C-w deletes previous word (by spaces) by default
#bind C-q to delete previous word-segment instead of "start(?) term output"
stty -ixon
bind '"\C-q": backward-kill-word'
#bind C-s to move cursor to previous [:space:] instead of "stop(?) term output"
bind -r '\C-s'
bind '"\C-s": shell-backward-word'
#bind C-d to go forword, not crush the shell
set -o ignoreeof
bind '"\C-d": shell-forward-word'
#miscellaneous useful inputrc binds
#bind shift-tab to 'see how the next autocomplete option would look on the cmd line'
bind '"\e[Z": menu-complete'
#don't make me hit tab twice to see multiple completion options
bind "set show-all-if-ambiguous on"
bind "set show-all-if-unmodified on"
#multi-complete shows filetypes by colors
bind "set colored-stats on"
#ellipsis at 3+ common characters with multi-complete
bind "set completion-prefix-display-length 3"
if [[ "$__os" == "mac" ]]; then
#tab complete is no longer case-sensitive? interesting...
bind "set completion-ignore-case on"
#tab complete is not -_ sensitive.
bind "set completion-map-case on"
fi
#vim mode is actually a super pain compared to emacs on the command line.
set -o emacs
#C-n/p now do double duty, so this is like the best of all 3 worlds? I'll take it
bind '"\C-p":history-search-backward'
bind '"\C-n":history-search-forward'
#makes aliases work with sudo
alias sudo='sudo '
#use sudo -i to become root and keep your bashrc & vimrc
alias -- -i='-E bash --rcfile $HOME/.bashrc'
#can't get it to work when becoming other users. sucks to suck.
alias apt-get='sudo apt-get'
alias systemctl='sudo systemctl'
alias sc='sudo systemctl'
alias scr='sudo systemctl restart'
alias firewall='sudo firewall-cmd'
alias fw='sudo firewall-cmd'
alias yum='sudo yum'
alias yumy='sudo yum install -y'
alias py='python'
# b/c sed needs i with an empty string on Mac to properly in-place
alias sd='sed -i"" -e'
#alias ugh = sudo !!
alias ugh='sudo $(history -p !!)'
# -a: dotfiles. -I: not those dotfiles. -C: color.
alias tree='tree -a -C -I ".git"'
#tries to force color: (G):BSD; (--color):GNU, adds / after dirs, * after execs, etc (F);
#and human readable sizes (h)
alias ls='ls --color -GFh'
alias la='ls --color -GFhla'
alias cd.='cd ../'
alias cd..='cd ../../'
alias cd...='cd ../../../'
alias cd....='cd ../../../../'
#is it running? sometimes you need all the args (i.e., for java processes) to fully grep
psg() {
ps -ef | grep -i $* | grep -v grep || \
ps -efwww | grep -i $* | grep -v grep
}
alias g.='grep '\''.'\'' -IrnHe'
alias f.='find . -name'