Tag Info

Hot answers tagged

22

I have found the solution to my problem in the ZSH documentation. Oh-my-zsh seems to map the ↑ and ↓ Keys to something like bindkey '\e[A' history-search-backward bindkey '\e[B' history-search-forward Which yields the exact behavior I described above. The ZSH Documentation describes the behavior of history-search-backward as Search backward in the ...


13

To prevent a command from being added to the history in the first place, make sure that the environment variable HISTCONTROL contains among its colon-separated values the value ignorespace, for example (add e.g. to .bashrc): $ export HISTCONTROL=ignorespace This will prevent any command with a leading space from being added to the history. You can then ...


10

You've probably got INC_APPEND_HISTORY set. The INC_APPEND_HISTORY option, from man zshoptions: This options works like APPEND_HISTORY except that new history lines are added to the $HISTFILE incrementally (as soon as they are entered), rather than waiting until the shell exits. The option that you want is APPEND_HISTORY: APPEND_HISTORY If ...


8

You can search the history using Ctrl+R and then type the search string (e.g. iw to find iwconfig). Then you can then still navigate through the history at that point with the up and down arrow keys, or press Ctrl+R again to find the previous occurence.


6

Your history is logged by your shell. Bash, for example, uses the file ~/.bash_history by default. It is also not limited by your current session, but the history is usually persisted beyond that, up to what the environment variables HISTSIZE and HISTFILESIZE allow. More information on how the history works in bash is available in it's man page, in the ...


5

Assuming your shell is bash, this question has been asked and answered on SO. Press Ctrl-U to delete the command line from the location of the cursor up to the beginning. Precede this by Ctrl-E if the cursor isn't at the end of the line. Or press Ctrl-C to cancel the current prompt and obtain a new one, which has the benefit that you still see the command ...


5

If you supply a negative argument to Alt-., it reverses direction. The easiest way to do that (with standard keybindings) is Alt-- (equivalent to an argument of -1). So, after one or more Alt-. keypresses, pressing Alt-- will cause the next Alt-. to go in the reverse direction. (Just ignore the argument dialog which appears when you press Alt--.)


5

There are two reasons why your script will not work as intended: The bash environment for a running script is "non-interactive" and does not have the history features enabled. The bash environment for a running script is independent from the environment you are interactively working in. Depending on your use case the easiest solution might be to source ...


4

After a bit of practice, I found how to use the workaround solution. I matched the correct syntax to print a filtered list, I did it with history | grep iwconfig (it wasn't so difficult after all); with the output I can use !n with the now easy-to-read filtered list.


4

Bash History Any new commands that have been issued in the active terminal can be appended to the .bash_history file with the following command: history -a The only tricky concept to understand is that each terminal has its own bash history list (loaded from the .bash_history file when you open the terminal) If you want to pull any new history that's ...


3

Look into sudosh. A link to the SourceForge page is: HERE (There may even be a package, depending on your repos/disto) You can "sudosh" into a shell and everything is recorded for that session. All sudosh sessions are recorded and saved with a date and time stamp appended to it automatically. (You can even grep/search the contents of the sudosh ...


3

tl;dr; for a in /home/* ; do cp $a/.bash_history /tmp/$a.bash_history ; done Longer version: for a in pattern loops over all items in a pattern. The pattern itself is stores in the variable called a. Examples: for a in * ; do echo $a ; done echo's all filenames. for a in /home/* ; do echo $a ; done echo's the names of all homedirs in /home. ...


3

You can bind a keystroke to do this for you. You can enter this at a Bash prompt: bind '"\C-q": "\C-a history -s \C-j"' or add this to your ~/.inputrc: "\C-q": "\C-a history -s \C-j" then you can type something and press Ctrl-q and it will be added to the history without being executed. The space before "history" causes the history command itself to ...


3

First of all, if the command you're about to issue is sensitive, unsafe, or you just don't need it cluttering up your history, it is best/quickest to just prevent it from entering the history in the first place. Make sure that $HISTCONTROL contains ignorespace: (bash)$ echo $HISTCONTROL ignoredups:ignorespace Then proceed any command you don't want in ...


3

Prevent sensible information from being stored in history file If you've hitted some password on command line, than realize that all commands are logged, you could either: Force exit current session without saving history: kill -9 $$ This will drop all current history. Hit on oppened bash session Up until sensible informations are shown, than Ctrl+w ...


3

When you log in to the remote machine, the sshd there allocates a pseudo-terminal and starts your login shell. Any processes you start, background or foreground, are child processes of that shell. (Read up on "fork", "parent process", and "child process"; use the "pstree" command to look at the state of the system.) If you disconnect, for example by closing ...


2

That's easy... if you know the corresponding option: unsetopt HIST_VERIFY Put this in your ~/.zshrc and do source ~/.zshrc if you want that behavior to be permanent. Explanation from man zshoptions: HIST_VERIFY Whenever the user enters a line with history expansion, don't execute the line directly; instead, perform history expansion and ...


2

actually it is in .bash_history. But when you su, you switch user, so you have to check .bash_history as the user you su'd to. When you su again, and type history, it will give you only the history from that user. Eg. you changed to root, so using history as root again, or checking the root-homefolder (default is /root) for .bash_history will give you all ...


2

You're not using bash, you're using sh. What that means depends on your system, on Debian and Ubuntu, /bin/sh is a symlink to dash so that's what your default shell is. dash does not have the functionality you want, you need to switch to another shell like bash or zsh. You can do this with the command chsh: $ chsh Password: Changing the login shell for ...


2

!?foo bar See http://zsh.sourceforge.net/Doc/Release/Expansion.html#Event-Designators Edit: No, you must not escape the spaces. If you need to add something that is not part of the history expansion, separate it with another ?, e.g.: echo hello echo foo !?echo hello? world # runs "echo hello world"


2

It is best to avoid aliases for anything other than simple, one-command substitutions. To use arguments, multiple commands, etc., you can define a function, accessing parameters the same way you would in a script: foo() { do_this do_that "$1" } cat() { command cat "$@" && echo ""; } (Normally functions override executables, so command cat ...


2

One common way to do this are through a git or git-like repository using tools like git-home or the tools that vcs-home built. The other common way is to use DropBox, box.net, or some other standard file sync tool to do this, and having your machine local bits source data from those. Both solve the offline problem for you, but may not be completely awesome ...


2

You're missing one line in your .bashrc. Add: PROMPT_COMMAND="$PROMPT_COMMAND;history -a" after shopt -s histappend PROMPT_COMMAND is executed just before the next prompt is printed (IIRC). You're right about when the history is written, by the way. The modified prompt command will flush the history.


2

Use the script command DESCRIPTION Script makes a typescript of everything printed on your terminal. It is useful for students who need a hardcopy record of an interactive session as proof of an assignment, as the typescript file can be printed out later with lpr(1).


2

You can setup a special zle widget to show only local history items: function only-local-history () { zle set-local-history 1 zle up-history zle set-local-history 0 } zle -N only-local-history Assuming, that ↑ is bound to up-line-or-history (I think that is default), you can bind this widget to another key stroke, like ...


2

Remember this is NOT a totally fool proof way to copy a users' activity. This is because there are options that the user can easily invoke to not put things in the history file. So I would not count on this as any sort of auditing mechanism. Also, as a root user, spying on other users' file unless there are specific and valid reasons for doing so is a ...


2

Try the -x option for bash: bash -x "PERL5LIB=${PERL5LIB}:/something/extra my-command.pl many arguments which I want to save" 2>&1 | tee -a my-command.log My test: $ bash -x -c "echo a bunch of difffernt arguments" + echo a bunch of difffernt arguments a bunch of difffernt arguments


2

Each new user connecting spawns a new sshd session with a specific PID. You could use pstree to print which commands are inherited from which sshd session, and then cross check this PID in /var/log/auth.log. Example (anonymized): I logged in to a remote server with 3 simultaneous sessions, with the same remote user. I now want to find out from which IP the ...


2

Here's one way to set up history-search-backward and history-search-forward: Step1: Put the following in your /etc/inputrc file: $if mode=emacs "\ep": history-search-backward "\en": history-search-forward $endif (Or simply put the following between in the existing if statement) "\ep": history-search-backward "\en": history-search-forward Step2: ...


2

Try the answer you linked to: Right-click on taskbar Go to Properties, Start Menu Check "Store and display a list of recently opened programs" under privacy. But then afterwards do this: Open the registry editor (Start -> Run -> regedit) Go to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer Add a key or amend the ...



Only top voted, non community-wiki answers of a minimum length are eligible