Commands tagged bashrc (15)

  • You need to have fortune and cowsay installed. It uses a subshell to list cow files in you cow directory (this folder is default for debian based systems, others might use another folder). you can add it to your .bashrc file to have it great you with something interesting every time you start a new session. Show Sample Output


    10
    fortune | cowsay -f $(ls /usr/share/cowsay/cows/ | shuf -n1)
    zed · 2010-07-08 02:57:52 8
  • * Add comment with # in your command * Later you can search that command on that comment with CTRL+R In the title command, you could search it later by invoking the command search tool by first typing CTRL+R and then typing "revert" Show Sample Output


    1
    svn up -r PREV # revert
    unixmonkey10719 · 2010-07-07 23:09:00 16
  • Makes bash-4.x like zsh. Automatic cd into a directory if a command with that name doesnt exists. Ready for your ~/.bashrc file Show Sample Output


    1
    shopt -s autocd
    xeor · 2010-12-12 20:53:33 3
  • This is useful if you use a shell with a lot of other users. You will be able to run "topu" to see your running processes instead of the complete 'top -u username'. Read more on alias: http://man.cx/alias


    1
    echo "alias topu='top -u USERNAME'" >> ~/.bash_aliases && source .bashrc
    TheLugal · 2011-07-07 08:24:06 3

  • 1
    echo 'export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"' >> .bashrc
    qdrizh · 2015-03-09 19:57:56 8
  • If you have a lot of hosts in /etc/hosts this would be very useful. Anyone have any more concise examples?


    0
    complete -W "$(sed 's/;.*//;' /etc/hosts | awk ' /^[[:digit:]]/ {$1 = "";print tolower($0)}')" ssh
    daodennis · 2011-06-20 03:54:45 3
  • Typographically speaking, it's generally the [accepted wisdom][1] that about 60 characters per line makes for optimal reading (would that more Web pages followed this convention!). I know I got tired of reading manpages with text as wide as my screen! However, the command above sets manwidth to 70 rather than 60 because paragraphs in manpages are generally indented. I recommend the following snippet for your .${SHELL}rc, which sets manwidth to 70 unless your terminal is smaller than 70 characters: function man () { if [[ $COLUMNS -gt 70 ]]; then MANWIDTH=70 command man $* else command man $* fi } [1]: https://en.wikipedia.org/wiki/Column_(typography)


    0
    MANWIDTH=70 man 7 man
    escondida · 2012-01-13 19:42:30 4
  • # AllInOne: Update what packages are available, upgrade to new versions, remove unneeded packages # (some are no longer needed, replaced by the ones from ap upgrade), check for dependencies # and clean local cached packages (saved on disk but not installed?,some are needed? [this only cleans unneeded unlike ap clean]). # aliases (copy into ~/.bashrc file): alias a='alias' a ap='apt-get' a r='ap autoremove -y' a up='ap update' a u='up && ap upgrade -y --show-progress && r && ap check && ap autoclean' # && means "and run if the previous succeeded", you can change it to ; to "run even if previous failed". I'm not sure if ap check should be before or after ap upgrade -y, you can also change the alias names. # To expand aliases in bash use ctrl alt e or see this ow.ly/zBKHs # For more useful aliases go to ow.ly/zBMOx


    0
    apt-get update && apt-get dist-upgrade -y --show-progress && apt-get autoremove -y && apt-get check && apt-get autoclean -y
    unixmonkey78577 · 2014-07-26 12:18:57 6
  • extract () { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; *.tar.gz) tar xvzf $1 ;; *.tar.xz) tar Jxvf $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 "don't know how to extract '$1'..." ;; esac read -r -p "Delete the compressed file? [Y/N] " response response=${response,,} # tolower if [[ $response =~ ^([Yy]es|YES|[Yy])$ ]]; then echo "rm '$1'" rm $1 fi else echo "'$1' is not a valid file!" fi }


    0
    extract file.tar.gz
    asdzxc · 2015-02-08 11:17:12 9
  • compress(){ # compress [FIle/Folder] [NewFileName].[Suffix] # compress image.jpg pictures.tar.bz2 # compress Document/ folder.rar if [ -f $1 ] || [ -d $1 ]; then case $2 in *.tar.bz2) tar -jcvf $2 $1 ;; *.tar.gz) tar -zcvpf $2 $1 ;; *.tar) tar -cvpf $2 $1 ;; *.zip) zip -r $2 $1 ;; *.rar) rar a -r -rr10 $2 $1 ;; *) echo "don't know how to compres '$1'..." ;; esac else echo "'$1' is not a valid file or folder2" fi }


    0
    compress pictures/ pictures.tar.gz
    asdzxc · 2015-02-08 11:28:30 13
  • to run write: Sound-volume 30% or Sound-volume 1% Sound-volume 100% Show Sample Output


    0
    alias Sound-volume='amixer -D pulse sset Master '
    asdzxc · 2015-02-08 11:36:44 8
  • alias screen-brightness='xbacklight -set' alias screen-off='xset dpms force standby' alias screen-min='xbacklight -set 1' alias screen-max='xbacklight -set 100' alias screen-inc='xbacklight -inc 10' alias screen-dec='xbacklight -dec 10'


    0
    xbacklight -set 100
    asdzxc · 2015-02-08 12:12:16 8
  • Adds a shortcut (bash alias) for a lightweight detachable 'multi-windowed' cli terminal session to bashrc. Uses 'abduco' (supersedes 'dtach') to implement a personal default detachable terminal session with a 'windowed' terminal UI provided by 'dvtm'. "-A" option allows the shortcut "wm" to be used to both instigate and re-attach to session "your_title_here". "-M" options stops 'dvtm' from changing your default mouse behavior.


    0
    echo 'alias wm="abduco -A your_title_here dvtm -M"' >> ~/.bashrc
    kevjonesin · 2016-03-06 07:42:38 13

  • -2
    complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
    sammcj · 2011-06-01 23:21:06 5
  • To install on centos 6.2 for Centos auto accept: yum install fortune* -y yum install cowsay* -y Removed the -f command as I dont know how, but it works without it. Almost the same but one folder higher =).


    -2
    fortune | cowsay $(ls/usr/share/cowsay | shuf -n1)
    cablegunmaster · 2014-10-23 10:09:44 9

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

diff two unsorted files without creating temporary files
bash/ksh subshell redirection (as file descriptors) used as input to diff

Rename files in batch

Grab IP address on machine with multiple interfaces
Instead of hard-coding in a check to scrape info from ifconfig based on a specific interface, do it in a more portable way. This works really well if you switch between wired, wireless, bluetooth or even VPN connections. You can get your current IP in a script (since it'll be something like tun0 instead of eth0 or wlan1). This uses a well known public ip address 8.8.8.8, but it doesn't actually connect to it, it just shows you the route it would take.

change ownership en masse of files owned by a specific user, including files and directories with spaces
In the example, uid 0 is root. foo:foo are the user:group you want to make owner and group. '.' is the "current directory and below." -print0 and -0 indicate that filenames and directories "are terminated by a null character instead of by whitespace."

Project your desktop using xrandr
HDMI-1 is the interface in the example, which can be obtained just by typing xrandr and surfing through the output. There are a hell lot of configurations that can be done but I prefer auto because it works in most cases. $ Lifesaver

Tail postfix current maillog and grep for "criteria"
Tail curren postfix maillog.

Change host name
With sed you can replace strings on the fly.

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Create multiple mp4 files using avidemux
Convert multiple files using avidemux. Version updated (thanks to the guys who helped me giving me hints about how to improve the command). Works with files whose name contains blank characters. One of the reasons why I love open source: everyone can take something "done" and improve it to make it better! If u have suggestions, please let me know.

convert doc to pdf
convert to pdf and many other formats and vise versa to get a list of supported formats, run $ unoconv --show


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: