Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Don't have much myself anymore, but love the mkcd function you have, might use that too.
-
octoxan1786y@JoshBent @killermenpl
It also just cd's if the directory already exists instead of throwing an error. =] -
flocke2616y
-
With oh-my-zsh git plugin, `git pull` is `gl` and `git push` is `gp`. And I use this terminal plugin called "autojump" which will jump to any path anywhere provided you give a fuzzy path name. And they prioritize based on the time you spent in each dir. And I also have a function where you accidentally unzipped a zip file with no parent dir, end up with a lot of files in current dir. Then that'll help remove it. If anyone interested, I'll post it.
-
@JoshBent
function ununzip() {
unzip -t $1 | awk '{print $2}' | tail -n +2 | xargs rm -rf
}
Undo the unzip that you accidentally spread a lot of files to $pwd and don't know which one is which one to delete manually.
function gtdy() {
git log --shortstat --since yesterday | grep 'changed, ' | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed:", files, "; lines inserted:", inserted, "; lines deleted:",deleted}'
}
Shows how many git commits you made, how many lines in total modified and changed
https://gist.github.com/the-c0d3r/...
I also use this, because I'm at the KVM console most of the time and I can't scrollback if I accidentally 'cat' a very long file. This will trigger 'less' if it is longer than terminal height, and 'cat' if shorter. -
# Add ssh if necessary and git pull
alias gpull='sshadd; git pull origin $(git_current_branch)'
#Add ssh if necessary and git push
alias gp='sshadd; git push'
alias grep='grep --color=auto'
alias ls='ls -h --color=tty'
# Install a package with aurman with no confirmation
alias aur='aurman -S --noedit --noconfirm --color always'
function sshadd()
{
ssh-add -l > /dev/null || ssh-add
}
function le { "$1" | less }
function cd { builtin cd "$1"; ls --color=tty; echo "$PWD" } -
Some commands I found over the internet:
alias cat='bat'
alias du='ncdu --color dark --exclude .git'
function extract() # Handy Extract Program.
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $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"
fi
} -
For creating a directory and then get into that directory, I present to you:
md () { mkdir -p "$@" && cd "$@"; } -
Noob64666yRegarding your last sentence, about the large project and being able to change directory to it.
I use ZSH, so it does that automatically. Really suggest that. -
alias fuckingconnect='sudo service network-manager restart'
Yes, I may have connectivity issues, especially when waking my computer from sleep mode -
@brunofontes could you pastebin/hastebin/.. the original formatted extract() function?
-
octoxan1786y@4nur44g If you use https://ohmyz.sh/ (works in any Linux terminal) the cd is implied. I love it, can just type a directories name or can just type .. to go up a directory.
... goes up 2
.... goes up 3
I still catch myself typing cd though sometimes even though it's not needed haha -
@octoxan
You should check this.
https://github.com/rupa/z
That's most number of times used shortcut. And absolutely I love it.
Related Rants
Share your most useful terminal aliases and functions.
alias gs='git status'
alias gcm='git commit -m'
alias push='git push'
alias pull='git pull'
alias hosts='sudo nano /etc/hosts'
alias glog='git log --graph --oneline --decorate -n 10 --color'
alias mykey='cat ~/.ssh/id_rsa.pub | xclip -sel clip'
function mkcd () {
mkdir -p -- "$1" && cd -P -- "$1"
}
As well as one for each major project (lets say 1+ weeks of dev time) to immediately cd to it from anywhere. How about you guys?
Always looking to improve my terminal commands, so am curious what everyone else uses for shortcuts.
question
terminal
shortcuts
aliases