Comments on: Bash Tips and Tricks http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/ I will not fix your computer. Tue, 04 Aug 2020 22:34:33 +0000 hourly 1 https://wordpress.org/?v=4.7.26 By: Poppy http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-26231 Thu, 24 Jan 2013 16:26:04 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-26231

Good topic and suggestions, all.

I’ve become much more reliant on my directory stack. Using one letter aliases to display them and to flip between them.

alias d='dirs -v'
alias 1='pushd +1'
alias 2= 'pushd +2'
alias 3='pushd +3' (etc.)

Recently I’ve started to save and restore the directory stack between shell session because I end up holding 5 or 6 useful locations in them. (Yes, my browser sessions have far too many tabs, too.)

Because shell sessions can terminate abruptly and lose your history and directory I like to do

PROMPT_COMMAND='history -a; dirs -l -p > ~/.bash_dirs_${HOST}'

and, during startup, check for the existence of the dir stack file and push each unique non-home entry onto the dir stack.

history -n ${HISTFILE}
if test -r ~/.bash_dirs_${HOST}; then
for d in `uniq ~/.bash_dirs_${HOST}` ; do
if test $d != $HOME; then
pushd -n "$d" > /dev/null
fi
done
fi

Reply  |  Quote
]]>
By: Stephen McQuay http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-25768 Fri, 11 Jan 2013 23:08:37 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-25768

I just added colored man pages to my .zshenv; so much more legible!!

Thanks!!

Reply  |  Quote
]]>
By: Luke Maciak http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-25689 Thu, 10 Jan 2013 01:19:41 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-25689

@ ylee:

Thanks, autojump seems kinda cool. I will definitely check it out. :)

Reply  |  Quote
]]>
By: ylee http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-25667 Wed, 09 Jan 2013 16:49:39 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-25667

I am rather fond of :

shopt -s dirspell # Correct dir spelling
shopt -s cdspell # Correct spelling
shopt -s autocd # autocd

as well as the autojump command.

I also use in my .inputrc file:

# Pre-pend sudo to a command
"\C-s":"\C-asudo \C-e"

And btw thanks for export IGNOREEOF=1 . That is handy and I am not sure how I missed that all these years, lol.

Reply  |  Quote
]]>
By: Alexei Matyushkin http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-25602 Tue, 08 Jan 2013 09:40:15 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-25602

@ Luke Maciak:
Ooups, sorry, there was no typo.

Reply  |  Quote
]]>
By: Luke Maciak http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-25581 Tue, 08 Jan 2013 01:13:37 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-25581

@ Alexei Matyushkin:

Which typo?

@ Guillaume:

Thanks, I fixed it. It should just be ignoreboth. :)

Reply  |  Quote
]]>
By: Scott Hansen http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-25555 Mon, 07 Jan 2013 19:51:23 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-25555

Thanks for the refresher! So next time it’ll be handy bash aliases and functions, right? :)

Scott

Reply  |  Quote
]]>
By: Guillaume http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-25545 Mon, 07 Jan 2013 11:38:46 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-25545

I don’t understand how this works:

# don't put duplicate lines in the history
export HISTCONTROL=ignoredups
# ... and ignore same successive entries.
export HISTCONTROL=ignoreboth

Doesn’t it mean that you override the HISTCONTROL value with the 2nd statement?

Reply  |  Quote
]]>
By: Alexei Matyushkin http://www.terminally-incoherent.com/blog/2013/01/07/bash-tips-and-tricks/#comment-25535 Mon, 07 Jan 2013 07:02:12 +0000 http://www.terminally-incoherent.com/blog/?p=13515#comment-25535

Hi, would you please fix a miscopypaste in cd - example, it now looks a bit confusing.

As for bash tips, I really like to put in command prompt the current dir’s git repo status and rvm gemset (if any). There are snippets over the internet in plenty.

Reply  |  Quote
]]>